[PySide] Adding items inside QGroupBox

Hi!
I´m in the way of learning coding some ui´s to create a tool in maya with PySide.
I´m struggeling adding widgets inside a QGroupBox.

My thinking was to add the layoutVert1 inside the mainLayout, so all the contents from the layoutVert1 (buttons) got moved inside the QGroupBox.
How can I add any widget inside the QGroupBox widget?

Thanks for your time guys! I really appreciate it!

P.S. I´m testing everything if it was a standardalone app. I don´t have maya installed in my laptop right now.

This is what I have so far (really simple):


import sys
from PySide import QtGui

class Example(QtGui.QWidget):

    def __init__(self):
        super(Example, self).__init__()
        self.setMinimumSize(200, 450)
        self.setWindowTitle('Test Window')
        self.initUI()

    def initUI(self):

        # create layouts
        self.mainLayout = QtGui.QVBoxLayout()
        self.layoutVert1 = QtGui.QVBoxLayout()

        # create widgets
        grp01 = QtGui.QGroupBox('Spine: ')
        grp01.setMaximumSize(200, 200)

        spineBtn = QtGui.QPushButton("Spine")
        
        # add widgets to the layouts
        self.mainLayout.addWidget(grp01)
        self.layoutVert1.addWidget(spineBtn)
        
        # layout setup
        self.setLayout(self.mainLayout)
        self.show()

def main():
    
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

Hello,

You have to assign a layout to the group box using something like : groupBox.setLayout(groupBoxLayout)

def initUI(self):

        # create layouts
        self.mainLayout = QtGui.QVBoxLayout()
        self.layoutVert1 = QtGui.QVBoxLayout()

        # create widgets
        grp01 = QtGui.QGroupBox('Spine: ')
        grp01.setMaximumSize(200, 200)

        spineBtn = QtGui.QPushButton("Spine")

        # add widgets to the layouts
        self.layoutVert1.addWidget(spineBtn)
        # assign the layout to the groupBox
        grp01.setLayout(layoutVert1)

        # add widgets to the layouts
        self.mainLayout.addWidget(grp01)
       
        # layout setup
        self.setLayout(self.mainLayout)
        self.show()

Cheers !!!

Thank you so much bujinkan. Now I have a clear idea how it works!
Really appreciate your time!