Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Groupbox occupies Whole Space on QMainWindow



  • Hi
    following is my piece of Code.
    I want to add Group box to QMainWindow.
    With my code the groupbox Whole QMainWindow.
    How do I place the GroupBox to a particular place

    
    class FormWidget(QtWidgets.QWidget):    
        def __init__(self, parent):        
            super(FormWidget, self).__init__(parent)
            self.layout = QtWidgets.QVBoxLayout(self)
            self.GroupBox = QtWidgets.QGroupBox("GroupBox")
            self.layout.addWidget(self.GroupBox)
            self.GroupBox.setGeometry(0, 0, 180, 320)
            self.setLayout(self.layout)
    
    
    class mainWindow(QtWidgets.QMainWindow):
        def __init__(self):        
            super().__init__()         
            uic.loadUi('ui/main.ui',self)     
            self.initUi()
            self.form_widget = FormWidget(self)
            self.setCentralWidget(self.form_widget)
    

  • Lifetime Qt Champion

    Hi,

    What kind of particular place do you have in mind ?



  • hi

    My intention was to show two groupbox on MainWindow...Then I read somewhere u can place only one widget on CMainWindow using setCentralWidget...


  • Lifetime Qt Champion

    That's correct there's one central widget but it can be composed of many widgets. Then you can also use the docker widgets.


Log in to reply