Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Layout, widgets not inside ???
QtWS25 Last Chance

Layout, widgets not inside ???

Scheduled Pinned Locked Moved Unsolved General and Desktop
87 Posts 9 Posters 9.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #56

    @SPlatten said in Layout, widgets not inside ???:

    Which clearly creates a new widget and positions it between QGroupBox and QVBoxLayout.

    What is for? The gaps between verticalLayoutWidget and groupBox can be handled with verticalLayout->setContentsMargins(11, 11, 11, 11); verticalLayoutWidget is not needed. Check the example in my link.

    SPlattenS 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      @SPlatten said in Layout, widgets not inside ???:

      Which clearly creates a new widget and positions it between QGroupBox and QVBoxLayout.

      What is for? The gaps between verticalLayoutWidget and groupBox can be handled with verticalLayout->setContentsMargins(11, 11, 11, 11); verticalLayoutWidget is not needed. Check the example in my link.

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by
      #57

      @JoeCFD , I think you misunderstand what I am saying. I used Qt Creator to build this example, I did the following:

      • Dragged Group Box from Containers palette and dropped onto centralWidget
      • Dragged Vertical Layout from Layouts palette and dropped onto Group Box
      • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
      • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
      • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
      • Edited text attribute for each control

      I did not do anything to add the mysterious verticalLayoutWidget which was added by Qt Creator. I am saying this works and its only because Qt Creator is doing something else instead of adding a QGroupBox, QVBoxLayout and child widgets.

      Kind Regards,
      Sy

      JoeCFDJ 1 Reply Last reply
      0
      • SPlattenS SPlatten

        @JoeCFD , I think you misunderstand what I am saying. I used Qt Creator to build this example, I did the following:

        • Dragged Group Box from Containers palette and dropped onto centralWidget
        • Dragged Vertical Layout from Layouts palette and dropped onto Group Box
        • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
        • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
        • Dragged Radio Button from Buttons palette and dropped onto Vertical Layout
        • Edited text attribute for each control

        I did not do anything to add the mysterious verticalLayoutWidget which was added by Qt Creator. I am saying this works and its only because Qt Creator is doing something else instead of adding a QGroupBox, QVBoxLayout and child widgets.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #58

        @SPlatten Nothing wrong with it. In your case, I think you do not need it. It is better to understand how this works. I did the same thing in my link with designer which does not have verticalLayoutWidget.

                groupBox = new QGroupBox(centralwidget);
                groupBox->setObjectName(QString::fromUtf8("groupBox"));
                verticalLayout = new QVBoxLayout(groupBox);
                verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
                radioButton = new QRadioButton(groupBox);
                radioButton->setObjectName(QString::fromUtf8("radioButton"));
        
                verticalLayout->addWidget(radioButton);
        
                radioButton_2 = new QRadioButton(groupBox);
                radioButton_2->setObjectName(QString::fromUtf8("radioButton_2"));
        
                verticalLayout->addWidget(radioButton_2);
        
                radioButton_3 = new QRadioButton(groupBox);
                radioButton_3->setObjectName(QString::fromUtf8("radioButton_3"));
        
                verticalLayout->addWidget(radioButton_3);
        
        
        SPlattenS 1 Reply Last reply
        1
        • JoeCFDJ JoeCFD

          @SPlatten Nothing wrong with it. In your case, I think you do not need it. It is better to understand how this works. I did the same thing in my link with designer which does not have verticalLayoutWidget.

                  groupBox = new QGroupBox(centralwidget);
                  groupBox->setObjectName(QString::fromUtf8("groupBox"));
                  verticalLayout = new QVBoxLayout(groupBox);
                  verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
                  radioButton = new QRadioButton(groupBox);
                  radioButton->setObjectName(QString::fromUtf8("radioButton"));
          
                  verticalLayout->addWidget(radioButton);
          
                  radioButton_2 = new QRadioButton(groupBox);
                  radioButton_2->setObjectName(QString::fromUtf8("radioButton_2"));
          
                  verticalLayout->addWidget(radioButton_2);
          
                  radioButton_3 = new QRadioButton(groupBox);
                  radioButton_3->setObjectName(QString::fromUtf8("radioButton_3"));
          
                  verticalLayout->addWidget(radioButton_3);
          
          
          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #59

          @JoeCFD , difference I can see is you set the parent for the radio buttons to group box, if this is correct then this is where I'm going wrong, because I'm setting the parent to the layout.

          Kind Regards,
          Sy

          JoeCFDJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @JoeCFD , difference I can see is you set the parent for the radio buttons to group box, if this is correct then this is where I'm going wrong, because I'm setting the parent to the layout.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #60

            @SPlatten If verticalLayoutWidget does not exist, groupBox is a natural choice. You can set their parents to be central widget as well. It is layouts which hold and organize widgets. Children are cleared when their parents are destroyed.

            Sometimes, I need to move a widget to another place in my app. What I do is to remove its parent first and add a new parent. Then add it to the layout of the new parent.

            An overlaid widget is made within its parent widget without being placed in any layout. Sure an overlaid widget can have a layout. In your case, verticalLayoutWidget is an overlaid widget since it is not in any layout.

            SPlattenS 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @SPlatten If verticalLayoutWidget does not exist, groupBox is a natural choice. You can set their parents to be central widget as well. It is layouts which hold and organize widgets. Children are cleared when their parents are destroyed.

              Sometimes, I need to move a widget to another place in my app. What I do is to remove its parent first and add a new parent. Then add it to the layout of the new parent.

              An overlaid widget is made within its parent widget without being placed in any layout. Sure an overlaid widget can have a layout. In your case, verticalLayoutWidget is an overlaid widget since it is not in any layout.

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #61

              @JoeCFD Well I've tried setting the parent to the groupbox, still the same, not right.

              Kind Regards,
              Sy

              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #62

                @SPlatten said in Layout, widgets not inside ???:

                verticalLayoutWidget->setGeometry(QRect(9, 29, 291, 161))

                your verticalLayoutWidget height is 161 and vertical margins of the layout are 11 * 2; The layout height for your radio buttons is 161 - 23 = 138 px. What is the height of your single radio button?

                what is the central widget width and height?
                groupBox->setGeometry(QRect(120, 170, 301, 201));
                its width has at least 120 + 301 px.

                SPlattenS 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @SPlatten said in Layout, widgets not inside ???:

                  verticalLayoutWidget->setGeometry(QRect(9, 29, 291, 161))

                  your verticalLayoutWidget height is 161 and vertical margins of the layout are 11 * 2; The layout height for your radio buttons is 161 - 23 = 138 px. What is the height of your single radio button?

                  what is the central widget width and height?
                  groupBox->setGeometry(QRect(120, 170, 301, 201));
                  its width has at least 120 + 301 px.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #63

                  @JoeCFD, I thought the widget containing the layout and other widgets would auto size ?

                  Kind Regards,
                  Sy

                  JKSHJ JoeCFDJ 2 Replies Last reply
                  0
                  • SPlattenS SPlatten

                    @JoeCFD, I thought the widget containing the layout and other widgets would auto size ?

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #64

                    @SPlatten Here's my suggestion:

                    1. Copy the working code from Qt Designer into a small test project. Build it and run it -- make sure the resulting GUI looks correct.
                    2. Gradually modify the working code to become more and more like your own custom code. Rebuild and re-run it after each small modification -- make sure the resulting GUI still looks correct at each step.
                    3. As soon as the GUI stops looking correct, investigate your latest modifications.

                    That will help you pinpoint exactly what's causing the GUI to look "not right".

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    SPlattenS 2 Replies Last reply
                    4
                    • JKSHJ JKSH

                      @SPlatten Here's my suggestion:

                      1. Copy the working code from Qt Designer into a small test project. Build it and run it -- make sure the resulting GUI looks correct.
                      2. Gradually modify the working code to become more and more like your own custom code. Rebuild and re-run it after each small modification -- make sure the resulting GUI still looks correct at each step.
                      3. As soon as the GUI stops looking correct, investigate your latest modifications.

                      That will help you pinpoint exactly what's causing the GUI to look "not right".

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #65

                      @JKSH , thank you, I will certainly give it a go.

                      Kind Regards,
                      Sy

                      1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @JoeCFD, I thought the widget containing the layout and other widgets would auto size ?

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by JoeCFD
                        #66

                        @SPlatten in designer after you finish your layout, click form (between edit and view)->preview in->fusion style
                        to preview your layout. Then resize the display of main window or dialog or widget to see if they resize properly. If not, change your layout.

                        SPlattenS 1 Reply Last reply
                        0
                        • JoeCFDJ JoeCFD

                          @SPlatten in designer after you finish your layout, click form (between edit and view)->preview in->fusion style
                          to preview your layout. Then resize the display of main window or dialog or widget to see if they resize properly. If not, change your layout.

                          SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by SPlatten
                          #67

                          @JoeCFD , No offence, I'm not sure you are reading or understanding what I'm trying to do. I have the everything in an XML file, when I read in the XML my code translates the XML at run-time into a GUI, I'm not using Qt Creator / Designer at all except for testing and feasibility testing.

                          There is some odd behaviour in what I'm trying to do and what Qt Creator does that as far as I can see isn't documented and seems to be additional glue.

                          Kind Regards,
                          Sy

                          1 Reply Last reply
                          0
                          • JKSHJ JKSH

                            @SPlatten Here's my suggestion:

                            1. Copy the working code from Qt Designer into a small test project. Build it and run it -- make sure the resulting GUI looks correct.
                            2. Gradually modify the working code to become more and more like your own custom code. Rebuild and re-run it after each small modification -- make sure the resulting GUI still looks correct at each step.
                            3. As soon as the GUI stops looking correct, investigate your latest modifications.

                            That will help you pinpoint exactly what's causing the GUI to look "not right".

                            SPlattenS Offline
                            SPlattenS Offline
                            SPlatten
                            wrote on last edited by
                            #68

                            @JKSH , I will try what you suggest, single stepping through my existing code this is what is done, using this XML:

                            <groupbox id="enSEX" eol="true" align="left" layout="vertical" title="Radios"
                            		  dbfield="vcSex" properties="QGroupBox { border-radius: 8px; background-color:#ff0000; }">
                            	<radiobutton id="rdoM" text="Male" default="true" position="0,0"/>
                            	<radiobutton id="rdoF" text="Female" position="1,0"/>
                            </groupbox>
                            

                            A node is created with a widget which I name with setObjectName to groupbox, id: enSEX, this node has a layout attribute so a layout QVBoxLayout is created:

                            ...
                                        } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
                                            mpobjLayout = new QVBoxLayout(mpobjWidget);
                                            strName = "QVBoxLayout";
                                        }
                                        if ( strName.isEmpty() != true ) {
                                            mpobjLayout->setObjectName(strName + QString(", id: %1")
                                                            .arg(strGetAttribute(clsXMLnode::mscszAttrID)));
                                        }
                            

                            The first radio button is created as a child of QGroupBox, it has the object name radiobutton, id: rdoM, so far the debugger shows:
                            Screenshot 2021-10-23 at 07.50.43.png
                            Then I carry on to the next radio button which has the object name radiobutton, id: rdoF, the result in the debugger doesn't look correct anymore and now shows:
                            Screenshot 2021-10-23 at 07.53.28.png
                            Where has radiobutton, id: rdoM gone and the output is still wrong:
                            Screenshot 2021-10-23 at 07.55.19.png
                            The radio buttons work correctly, the layout has the title and correct style but why or why do the radio buttons appear outside of the layout?

                            Kind Regards,
                            Sy

                            JonBJ 1 Reply Last reply
                            0
                            • SPlattenS SPlatten

                              @JKSH , I will try what you suggest, single stepping through my existing code this is what is done, using this XML:

                              <groupbox id="enSEX" eol="true" align="left" layout="vertical" title="Radios"
                              		  dbfield="vcSex" properties="QGroupBox { border-radius: 8px; background-color:#ff0000; }">
                              	<radiobutton id="rdoM" text="Male" default="true" position="0,0"/>
                              	<radiobutton id="rdoF" text="Female" position="1,0"/>
                              </groupbox>
                              

                              A node is created with a widget which I name with setObjectName to groupbox, id: enSEX, this node has a layout attribute so a layout QVBoxLayout is created:

                              ...
                                          } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
                                              mpobjLayout = new QVBoxLayout(mpobjWidget);
                                              strName = "QVBoxLayout";
                                          }
                                          if ( strName.isEmpty() != true ) {
                                              mpobjLayout->setObjectName(strName + QString(", id: %1")
                                                              .arg(strGetAttribute(clsXMLnode::mscszAttrID)));
                                          }
                              

                              The first radio button is created as a child of QGroupBox, it has the object name radiobutton, id: rdoM, so far the debugger shows:
                              Screenshot 2021-10-23 at 07.50.43.png
                              Then I carry on to the next radio button which has the object name radiobutton, id: rdoF, the result in the debugger doesn't look correct anymore and now shows:
                              Screenshot 2021-10-23 at 07.53.28.png
                              Where has radiobutton, id: rdoM gone and the output is still wrong:
                              Screenshot 2021-10-23 at 07.55.19.png
                              The radio buttons work correctly, the layout has the title and correct style but why or why do the radio buttons appear outside of the layout?

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #69

                              @SPlatten
                              I am just jumping in here. I have not read & digested all previous posts here, and I don't intend to, but just a comment.

                              Will take a good look, because the verticalLayoutWidget looks like its added by Qt Creator and is obviously required, and thats something thats missing in my code.

                              I did not do anything to add the mysterious verticalLayoutWidget which was added by Qt Creator. I am saying this works and its only because Qt Creator is doing something else instead of adding a QGroupBox, QVBoxLayout and child widgets.

                              I do not think you should have any such "verticalLayoutWidget" widget.

                              Dragged Vertical Layout from Layouts palette and dropped onto Group Box

                              This is not the right thing to do. The correct actions in Designer should be:

                              1. Drag QGroupBox onto canvas.
                              2. Next drag one QRadioButton onto the QGroupBox widget.
                              3. Now --- and only after step #2 can this be done --- right click on the QGroupBox. From the bottom item which reads Lay out pick Lay Out Vertically.

                              This is the (irritating) way Designer requires you to place a layout on a widget (took me ages to appreciate this when I first started using Designer). It does not allow you to do so till after the container has had at least one child widget added. This creates a different structure from your "Dragged Vertical Layout from Layouts palette", which you should not do. (Indeed, if you do your way in Designer and look you will see the group box has a "no entry" sign indicating this is incorrect, it is missing its own layout.)

                              To address whatever your issue is. By now you have spent a large amount of time asking about your existing, complex code. Instead take the example from https://doc.qt.io/qt-5/qgroupbox.html#details. Get rid of all your code. Does that draw your widgets/group box/layout correctly? Assuming it does, build back from there to your real code, or down from your code to the working code. (For example, get rid of all your parsing code, just test as you incrementally add hard-coded group boxes, layouts and radiobuttons to mirror what you would like to be doing when it's actually reading your XML file.)

                              SPlattenS 2 Replies Last reply
                              1
                              • JonBJ JonB

                                @SPlatten
                                I am just jumping in here. I have not read & digested all previous posts here, and I don't intend to, but just a comment.

                                Will take a good look, because the verticalLayoutWidget looks like its added by Qt Creator and is obviously required, and thats something thats missing in my code.

                                I did not do anything to add the mysterious verticalLayoutWidget which was added by Qt Creator. I am saying this works and its only because Qt Creator is doing something else instead of adding a QGroupBox, QVBoxLayout and child widgets.

                                I do not think you should have any such "verticalLayoutWidget" widget.

                                Dragged Vertical Layout from Layouts palette and dropped onto Group Box

                                This is not the right thing to do. The correct actions in Designer should be:

                                1. Drag QGroupBox onto canvas.
                                2. Next drag one QRadioButton onto the QGroupBox widget.
                                3. Now --- and only after step #2 can this be done --- right click on the QGroupBox. From the bottom item which reads Lay out pick Lay Out Vertically.

                                This is the (irritating) way Designer requires you to place a layout on a widget (took me ages to appreciate this when I first started using Designer). It does not allow you to do so till after the container has had at least one child widget added. This creates a different structure from your "Dragged Vertical Layout from Layouts palette", which you should not do. (Indeed, if you do your way in Designer and look you will see the group box has a "no entry" sign indicating this is incorrect, it is missing its own layout.)

                                To address whatever your issue is. By now you have spent a large amount of time asking about your existing, complex code. Instead take the example from https://doc.qt.io/qt-5/qgroupbox.html#details. Get rid of all your code. Does that draw your widgets/group box/layout correctly? Assuming it does, build back from there to your real code, or down from your code to the working code. (For example, get rid of all your parsing code, just test as you incrementally add hard-coded group boxes, layouts and radiobuttons to mirror what you would like to be doing when it's actually reading your XML file.)

                                SPlattenS Offline
                                SPlattenS Offline
                                SPlatten
                                wrote on last edited by
                                #70

                                @JonB , thank you, I will read, digest and git it a go.

                                Kind Regards,
                                Sy

                                1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @SPlatten
                                  I am just jumping in here. I have not read & digested all previous posts here, and I don't intend to, but just a comment.

                                  Will take a good look, because the verticalLayoutWidget looks like its added by Qt Creator and is obviously required, and thats something thats missing in my code.

                                  I did not do anything to add the mysterious verticalLayoutWidget which was added by Qt Creator. I am saying this works and its only because Qt Creator is doing something else instead of adding a QGroupBox, QVBoxLayout and child widgets.

                                  I do not think you should have any such "verticalLayoutWidget" widget.

                                  Dragged Vertical Layout from Layouts palette and dropped onto Group Box

                                  This is not the right thing to do. The correct actions in Designer should be:

                                  1. Drag QGroupBox onto canvas.
                                  2. Next drag one QRadioButton onto the QGroupBox widget.
                                  3. Now --- and only after step #2 can this be done --- right click on the QGroupBox. From the bottom item which reads Lay out pick Lay Out Vertically.

                                  This is the (irritating) way Designer requires you to place a layout on a widget (took me ages to appreciate this when I first started using Designer). It does not allow you to do so till after the container has had at least one child widget added. This creates a different structure from your "Dragged Vertical Layout from Layouts palette", which you should not do. (Indeed, if you do your way in Designer and look you will see the group box has a "no entry" sign indicating this is incorrect, it is missing its own layout.)

                                  To address whatever your issue is. By now you have spent a large amount of time asking about your existing, complex code. Instead take the example from https://doc.qt.io/qt-5/qgroupbox.html#details. Get rid of all your code. Does that draw your widgets/group box/layout correctly? Assuming it does, build back from there to your real code, or down from your code to the working code. (For example, get rid of all your parsing code, just test as you incrementally add hard-coded group boxes, layouts and radiobuttons to mirror what you would like to be doing when it's actually reading your XML file.)

                                  SPlattenS Offline
                                  SPlattenS Offline
                                  SPlatten
                                  wrote on last edited by
                                  #71

                                  @JonB , I can get it to work easy enough in Qt Creator, but for some reason unknown to me, trying to replicate the same in code doesn't do the same.

                                  1. I create a QGroupBox
                                  2. I add two instances of QRadioButton to the QGroupBox by setting the QGroupBox as the parent of the QRadioButton's.
                                  3. There is no option to select a layout in code so I set the layout using setLayout passing an instance of QVBoxLayout.

                                  Doing this just ends up with the exact same results, the QGroupBox appears above the radio buttons and the Radio buttons are not inside the QGroupBox. I change the layout to QHBoxLayout no difference in appearance, the radio buttons still appear above each other and outside the QGroupBox.

                                  Kind Regards,
                                  Sy

                                  JonBJ 1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #72

                                    In code:

                                    • create QGroupBox
                                    • create buttons (no need for parent)
                                    • create layout (without any parent !)
                                    • add buttons to layout
                                    • set layout on QGroupBox

                                    Other possibility:

                                    • create QGroupBox
                                    • create layout (without any parent !)
                                    • set layout on QGroupBox
                                    • create buttons (no need for parent)
                                    • add buttons to layout

                                    Yet another possibility:

                                    • create QGroupBox
                                    • create layout with QGroupBox object as parent
                                    • create buttons (no need for parent)
                                    • add buttons to layout

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    SPlattenS 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      In code:

                                      • create QGroupBox
                                      • create buttons (no need for parent)
                                      • create layout (without any parent !)
                                      • add buttons to layout
                                      • set layout on QGroupBox

                                      Other possibility:

                                      • create QGroupBox
                                      • create layout (without any parent !)
                                      • set layout on QGroupBox
                                      • create buttons (no need for parent)
                                      • add buttons to layout

                                      Yet another possibility:

                                      • create QGroupBox
                                      • create layout with QGroupBox object as parent
                                      • create buttons (no need for parent)
                                      • add buttons to layout
                                      SPlattenS Offline
                                      SPlattenS Offline
                                      SPlatten
                                      wrote on last edited by
                                      #73

                                      @SGaist , thank you, will try this now.

                                      Kind Regards,
                                      Sy

                                      1 Reply Last reply
                                      0
                                      • SPlattenS SPlatten

                                        @JonB , I can get it to work easy enough in Qt Creator, but for some reason unknown to me, trying to replicate the same in code doesn't do the same.

                                        1. I create a QGroupBox
                                        2. I add two instances of QRadioButton to the QGroupBox by setting the QGroupBox as the parent of the QRadioButton's.
                                        3. There is no option to select a layout in code so I set the layout using setLayout passing an instance of QVBoxLayout.

                                        Doing this just ends up with the exact same results, the QGroupBox appears above the radio buttons and the Radio buttons are not inside the QGroupBox. I change the layout to QHBoxLayout no difference in appearance, the radio buttons still appear above each other and outside the QGroupBox.

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by JonB
                                        #74

                                        @SPlatten said in Layout, widgets not inside ???:

                                        I create a QGroupBox
                                        I add two instances of QRadioButton to the QGroupBox by setting the QGroupBox as the parent of the QRadioButton's.
                                        There is no option to select a layout in code so I set the layout using setLayout passing an instance of QVBoxLayout.

                                        I referred you to copy from https://doc.qt.io/qt-5/qgroupbox.html#details, all you have to do is copy the code example there. Obviously you have to add buttons onto the layout with QVBoxLayout::addWidget();, else you're not putting them on a layout. Yet you do not mention that in your steps.....??

                                        SPlattenS 1 Reply Last reply
                                        0
                                        • JonBJ JonB

                                          @SPlatten said in Layout, widgets not inside ???:

                                          I create a QGroupBox
                                          I add two instances of QRadioButton to the QGroupBox by setting the QGroupBox as the parent of the QRadioButton's.
                                          There is no option to select a layout in code so I set the layout using setLayout passing an instance of QVBoxLayout.

                                          I referred you to copy from https://doc.qt.io/qt-5/qgroupbox.html#details, all you have to do is copy the code example there. Obviously you have to add buttons onto the layout with QVBoxLayout::addWidget();, else you're not putting them on a layout. Yet you do not mention that in your steps.....??

                                          SPlattenS Offline
                                          SPlattenS Offline
                                          SPlatten
                                          wrote on last edited by
                                          #75

                                          @JonB , I have tried adding the widgets to the layout and also tried using the layout as the parent for the widgets, neither have worked.

                                          Kind Regards,
                                          Sy

                                          JonBJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved