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 ???
Forum Updated to NodeBB v4.3 + New Features

Layout, widgets not inside ???

Scheduled Pinned Locked Moved Unsolved General and Desktop
87 Posts 9 Posters 12.1k Views 4 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    For quick debugging purpose you should print the pointer value of each object you test to ensure you are not passing in the else clause unexpectedly.

    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

      Hi,

      For quick debugging purpose you should print the pointer value of each object you test to ensure you are not passing in the else clause unexpectedly.

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

      @SGaist , I'm not really sure what or how this would help? I'm checking the pointers everywhere before use.

      Kind Regards,
      Sy

      mrjjM 1 Reply Last reply
      0
      • SPlattenS SPlatten

        @SGaist , I'm not really sure what or how this would help? I'm checking the pointers everywhere before use.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @SPlatten
        Hi
        What parent do you assign the radio buttons?

        QWidget* pobjWidget(pobjGetWidget());

        SPlattenS 1 Reply Last reply
        0
        • mrjjM mrjj

          @SPlatten
          Hi
          What parent do you assign the radio buttons?

          QWidget* pobjWidget(pobjGetWidget());

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

          @mrjj , in my XML file:

          <groupbox id="enSEX" eol="true" align="left" layout="vertical" 
          	  dbfield="vcSex">
          	<radiobutton id="rdoM" text="Male" default="true" position="0,0"/>
          	<radiobutton id="rdoF" text="Female" position="1,0"/>
          </groupbox>
          

          Where groupbox results in a QGroupBox being created and each radiobutton results in a QRadioButton.

          In my class constructor for clsQtGroupBox which is derived from QGroupBox I check the node attribute and create a layout if specified:

          QString strLayout(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrLayout));
          if ( strLayout.compare(clsXMLnode::mscszLayoutGrid) == 0 ) {
              mpobjNode->mpobjLayout = new QGridLayout(pParent);
          } else if ( strLayout.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) {
              mpobjNode->mpobjLayout = new QHBoxLayout(pParent);
          } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
              mpobjNode->mpobjLayout = new QVBoxLayout(pParent);
          }
          if ( mpobjNode->mpobjLayout != nullptr ) {
              setLayout(mpobjNode->mpobjLayout);
          }
          

          mpobjLayout is initialised to nullptr in the mpobjNode constructor. I've checked the source in debug and each radio button has the QGroupBox as a parent.

          I think this could be the problem as looking at:
          https://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html

          It looks like the parent of the radio buttons should be the layout not the group box.

          After creating the layout I can see that mpobjLayout is not nullptr.

          Calling mpobjLayout->widget() returns nullptr, why?
          Could it be because mpobjLayout is defined as QLayout?

          I thought this should be compatible with QGridLayout, QHBoxLayout and QVBoxLayout since
          QGridLayout is derived from QLayout
          QHBoxLayout and QVBoxLayout are derived from QBoxLayout which is derived from QLayout.

          Kind Regards,
          Sy

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

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

            QString strLayout(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrLayout));
            if ( strLayout.compare(clsXMLnode::mscszLayoutGrid) == 0 ) {
            mpobjNode->mpobjLayout = new QGridLayout(pParent);
            } else if ( strLayout.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) {
            mpobjNode->mpobjLayout = new QHBoxLayout(pParent);
            } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
            mpobjNode->mpobjLayout = new QVBoxLayout(pParent);
            }
            if ( mpobjNode->mpobjLayout != nullptr ) {
            setLayout(mpobjNode->mpobjLayout);
            }

            You know that passing a parent to a layout automatically applies that layout on the parent given ?

            Following the logic of that block of code, you should replace pParent by this and drop the last if.

            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
            1
            • SGaistS SGaist

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

              QString strLayout(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrLayout));
              if ( strLayout.compare(clsXMLnode::mscszLayoutGrid) == 0 ) {
              mpobjNode->mpobjLayout = new QGridLayout(pParent);
              } else if ( strLayout.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) {
              mpobjNode->mpobjLayout = new QHBoxLayout(pParent);
              } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
              mpobjNode->mpobjLayout = new QVBoxLayout(pParent);
              }
              if ( mpobjNode->mpobjLayout != nullptr ) {
              setLayout(mpobjNode->mpobjLayout);
              }

              You know that passing a parent to a layout automatically applies that layout on the parent given ?

              Following the logic of that block of code, you should replace pParent by this and drop the last if.

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

              @SGaist , I've modified the source and tested again, still the same result:

              QString strLayout(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrLayout));
              if ( strLayout.isEmpty() != true ) {
                  QWidget* pobjWidget(mpobjNode->pobjGetWidget());
                  if ( pobjWidget != nullptr ) {
                      if ( strLayout.compare(clsXMLnode::mscszLayoutGrid) == 0 ) {
                          mpobjNode->mpobjLayout = new QGridLayout(pobjWidget);
                      } else if ( strLayout.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) {
                          mpobjNode->mpobjLayout = new QHBoxLayout(pobjWidget);
                      } else if ( strLayout.compare(clsXMLnode::mscszLayoutVertical) == 0 ) {
                          mpobjNode->mpobjLayout = new QVBoxLayout(pobjWidget);
                      }
                  }
              }
              

              In the above code:
              this points to the an instance of clsQtGroupBox.
              mpobjNode is a pointer to the XML node, in this case groupbox.
              pobjWidget is a pointer to the instance of QGroupBox.
              mpobjLayout is a pointer to the layout created using the pobjWidget as a parent.

              Later in the code where the radio buttons or other nodes are created and added to parents:

               if ( mpobjParent != nullptr ) {
                  bool blnAppend(true);
              //Does the parent node have a layout?
                  QLayout* pobjLayout(mpobjParent->pobjGetLayout());
                  if ( pobjLayout != nullptr ) {
              //Yes, add this widget to the layout
                      QWidget* pobjWidget(pobjGetWidget());
                      if ( pobjWidget != nullptr ) {
                          pobjLayout->addWidget(pobjWidget);
                          blnAppend = false;
                      }
                  }
              //Update the parent adding 'this' node to it's child list
                  mpobjParent->appendChild(this, blnAppend);
              }
              

              this points to an instance of clsQtRadioButton
              mpobjParent is a pointer to the parent clsQtGroupBox
              pobjLayout is a pointer to the layout QLayout created in the previous section.
              pobjWidget is a pointer to QRadioButton widget

              Unfortunately this still results in:
              Screenshot 2021-10-17 at 08.13.40.png

              Kind Regards,
              Sy

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

                The issue I am seeing here is that your children widgets seems to need to know stuff about their parent. Why ?

                Following a top down approach, you start with the "master" widget that for example is your QGroupBox, add a layout to it, then next step, add the two QRadioButtons one after the other.

                If that group box is inside another widget, then it's not its problem. The positioning within a parent widget's layout or in coordinates is the responsibility of said parent.

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

                P 1 Reply Last reply
                1
                • SGaistS SGaist

                  The issue I am seeing here is that your children widgets seems to need to know stuff about their parent. Why ?

                  Following a top down approach, you start with the "master" widget that for example is your QGroupBox, add a layout to it, then next step, add the two QRadioButtons one after the other.

                  If that group box is inside another widget, then it's not its problem. The positioning within a parent widget's layout or in coordinates is the responsibility of said parent.

                  P Offline
                  P Offline
                  Publicnamer
                  wrote on last edited by
                  #9

                  @SGaist I would just like to point out that in many cases manual layout of widgets saves a lot of development time and the code is perfectly understandable (unless sloppily written). The present-day focus on XML layout is a fad that is wasting a lot of people's time.

                  JKSHJ 1 Reply Last reply
                  0
                  • P Publicnamer

                    @SGaist I would just like to point out that in many cases manual layout of widgets saves a lot of development time and the code is perfectly understandable (unless sloppily written). The present-day focus on XML layout is a fad that is wasting a lot of people's time.

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

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

                    I would just like to point out that in many cases manual layout of widgets saves a lot of development time and the code is perfectly understandable (unless sloppily written). The present-day focus on XML layout is a fad that is wasting a lot of people's time.

                    For small projects, perhaps.

                    I, for one, find that a WYSIWYG editor helps me get my GUI up and running faster than manually coding its layouts in C++. And for very large projects, it's helpful to enable a front-end designer and back-end developer to work in parallel.

                    Please note that to OP's use-case is not the same as how we typically use XML .ui files in Qt. It is definitely not our "present-day focus".

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

                    1 Reply Last reply
                    2
                    • AxelViennaA Offline
                      AxelViennaA Offline
                      AxelVienna
                      wrote on last edited by
                      #11

                      If you want to know if your QRadioButtons are inside our outside your layout, obtain and print the pointers upon creation. At the end of your code, read the widget pointers of your layout and compare them like that:

                      for (int i = 0; i < yourLayout->count(); ++i)
                      {
                        QWidget *widget = gridLayout->itemAt(i)->widget();
                        // qdebug or cout the pointer or write it to a vector
                      }
                      

                      That is the only way to figure out if there is a bug in your complex code or a Qt misbehavior.

                      C++ and Python walk into a bar. C++ reuses the first glass.

                      SPlattenS 1 Reply Last reply
                      2
                      • AxelViennaA AxelVienna

                        If you want to know if your QRadioButtons are inside our outside your layout, obtain and print the pointers upon creation. At the end of your code, read the widget pointers of your layout and compare them like that:

                        for (int i = 0; i < yourLayout->count(); ++i)
                        {
                          QWidget *widget = gridLayout->itemAt(i)->widget();
                          // qdebug or cout the pointer or write it to a vector
                        }
                        

                        That is the only way to figure out if there is a bug in your complex code or a Qt misbehavior.

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

                        @AxelVienna , I modified my code setting the objectName for each widget I then added:

                                if ( pobjWidget != nullptr ) {
                        //Set the object name
                                    QString strID(strGetAttribute(clsXMLnode::mscszAttrID)),
                                            strName(mstrName);
                                    if ( strID.isEmpty() != true ) {
                                        strName += ", id: " + strID;
                                    }
                                    pobjWidget->setObjectName(strName);
                                }
                                if ( pobjParent != nullptr && pobjParent->mpobjLayout != nullptr ) {
                                    pobjParent->mpobjLayout->addWidget(pobjWidget);
                                    for (int i = 0; i < pobjParent->mpobjLayout->count(); ++i) {
                                      QWidget *widget = pobjParent->mpobjLayout->itemAt(i)->widget();
                                      QString strWidget(widget->objectName()), strParent(widget->parentWidget()->objectName());
                        qDebug() << strWidget << ", parent: " << strParent;
                                    }
                                }
                        

                        I checked in the debugger and strWidget is exactly what I expected to see, but there is still no difference in the output.

                        In the above the output is:

                        radiobutton, id: rdoM, parent: groupbox, id: enSEX
                        radiobutton, id: rdoF, parent: groupbox, id: enSEX
                        

                        This is using the XML:

                        <groupbox id="enSEX" eol="true" align="left" layout="vertical" 
                        		     dbfield="vcSex">
                        	<radiobutton id="rdoM" text="Male" default="true" position="0,0"/>
                        	<radiobutton id="rdoF" text="Female" position="1,0"/>
                        </groupbox>
                        

                        The debug output looks correct, but the screen still looks the same.

                        Kind Regards,
                        Sy

                        1 Reply Last reply
                        0
                        • AxelViennaA Offline
                          AxelViennaA Offline
                          AxelVienna
                          wrote on last edited by
                          #13

                          As @Publicnamer said, creating an UI fully programmatically takes time and creates fuzz. Your debugging just tells us that two radio buttons are inside a group box. You have to look at the pointers themselves to make sure your layout is really the I’m your group box and the radio buttons are the ones you mean.

                          C++ and Python walk into a bar. C++ reuses the first glass.

                          SPlattenS 1 Reply Last reply
                          0
                          • AxelViennaA AxelVienna

                            As @Publicnamer said, creating an UI fully programmatically takes time and creates fuzz. Your debugging just tells us that two radio buttons are inside a group box. You have to look at the pointers themselves to make sure your layout is really the I’m your group box and the radio buttons are the ones you mean.

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

                            @AxelVienna , time is what I have, I know the nodes are correct, I used the information on this page as a guide:
                            https://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html

                                QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
                            
                                QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                                QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                                QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
                            
                                radio1->setChecked(true);
                                QVBoxLayout *vbox = new QVBoxLayout;
                                vbox->addWidget(radio1);
                                vbox->addWidget(radio2);
                                vbox->addWidget(radio3);
                                vbox->addStretch(1);
                                groupBox->setLayout(vbox);
                            
                                return groupBox;
                            }
                            

                            My clsQtGroupBox is derived from my clsXMLnode class, this class has a member called mpobjLayout which is created when the node has a layout attribute. The group box node has a layout attribute and thats why it has a layout, if the parent of the radio buttons has a layout then they are added to the layout and the layout is set as the layout of the group box. I just can't see how my code differs from the example.

                            Each instance of clsXMLnode has a QWidget which is QGroupBox, QRadioButton etc.

                            Kind Regards,
                            Sy

                            SGaistS 1 Reply Last reply
                            0
                            • AxelViennaA Offline
                              AxelViennaA Offline
                              AxelVienna
                              wrote on last edited by
                              #15

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

                              if the parent of the radio buttons has a layout then they are added to the layout

                              That may be the problem. What if the parent hasn’t got a layout (yet)? Does your code throw an exception, returns an error or just stops? Or does it place the buttons outside the group box? I tend to believe that your code provokes the behaviour since I have never seen a bug in Qt that fiddles with widget assignments.

                              C++ and Python walk into a bar. C++ reuses the first glass.

                              SPlattenS 1 Reply Last reply
                              2
                              • AxelViennaA AxelVienna

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

                                if the parent of the radio buttons has a layout then they are added to the layout

                                That may be the problem. What if the parent hasn’t got a layout (yet)? Does your code throw an exception, returns an error or just stops? Or does it place the buttons outside the group box? I tend to believe that your code provokes the behaviour since I have never seen a bug in Qt that fiddles with widget assignments.

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

                                @AxelVienna , I manage everything, only the nodes I add have widgets and only the widgets I assign a layout have a layout… unless QT is doing something I’m not aware of.

                                Kind Regards,
                                Sy

                                1 Reply Last reply
                                0
                                • AxelViennaA Offline
                                  AxelViennaA Offline
                                  AxelVienna
                                  wrote on last edited by
                                  #17

                                  A bold statement…. A lot of volunteers have read through your posts, tried to help and advise. If there are reasons to maintain your approach and you can’t find the bug, you have to hire an expert.

                                  C++ and Python walk into a bar. C++ reuses the first glass.

                                  1 Reply Last reply
                                  1
                                  • SPlattenS SPlatten

                                    @AxelVienna , time is what I have, I know the nodes are correct, I used the information on this page as a guide:
                                    https://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html

                                        QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
                                    
                                        QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                                        QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                                        QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
                                    
                                        radio1->setChecked(true);
                                        QVBoxLayout *vbox = new QVBoxLayout;
                                        vbox->addWidget(radio1);
                                        vbox->addWidget(radio2);
                                        vbox->addWidget(radio3);
                                        vbox->addStretch(1);
                                        groupBox->setLayout(vbox);
                                    
                                        return groupBox;
                                    }
                                    

                                    My clsQtGroupBox is derived from my clsXMLnode class, this class has a member called mpobjLayout which is created when the node has a layout attribute. The group box node has a layout attribute and thats why it has a layout, if the parent of the radio buttons has a layout then they are added to the layout and the layout is set as the layout of the group box. I just can't see how my code differs from the example.

                                    Each instance of clsXMLnode has a QWidget which is QGroupBox, QRadioButton etc.

                                    SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

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

                                    I just can't see how my code differs from the example.

                                    Parent handling from child widgets, that's the main difference I already suggested to avoid.

                                    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
                                    1
                                    • JoeCFDJ Offline
                                      JoeCFDJ Offline
                                      JoeCFD
                                      wrote on last edited by JoeCFD
                                      #19

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

                                      QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
                                      
                                      QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                                      QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                                      QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
                                      
                                      radio1->setChecked(true);
                                      QVBoxLayout *vbox = new QVBoxLayout;
                                      vbox->addWidget(radio1);
                                      vbox->addWidget(radio2);
                                      vbox->addWidget(radio3);
                                      vbox->addStretch(1);
                                      groupBox->setLayout(vbox);
                                      
                                      return groupBox;
                                      
                                          auto groupBox = new QGroupBox(tr("Exclusive Radio Buttons"), this );
                                      
                                          auto radio1 = new QRadioButton(tr("&Radio button 1"), groupBox);
                                          auto radio2 = new QRadioButton(tr("R&adio button 2"), groupBox);
                                          auto radio3 = new QRadioButton(tr("Ra&dio button 3"), groupBox);
                                      
                                          auto button_group = new QButtonGroup;
                                          button_group->addButton(radio1) ; 
                                          button_group->addButton(radio2) ;
                                          button_group->addButton(radio3) ;
                                          button_group->setExclusive( true );
                                          radio1->setChecked(true);
                                      
                                          auto vbox = new QVBoxLayout( groupBox );
                                          vbox->addWidget(radio1);
                                          vbox->addWidget(radio2);
                                          vbox->addWidget(radio3);
                                          vbox->addStretch(1);
                                      
                                          return groupBox;
                                      
                                      SPlattenS 1 Reply Last reply
                                      0
                                      • JoeCFDJ Offline
                                        JoeCFDJ Offline
                                        JoeCFD
                                        wrote on last edited by JoeCFD
                                        #20
                                            QString group_style_sheet = QString("QGroupBox{border: %1px solid gray;border-radius: %2px;margin-top: %3px;}" )
                                                                                                                 .arg( m_groupBorderThickness )
                                                                                                                .arg( m_groupBorderRadius )
                                                                                                                .arg( text_font_size * 1.6 );
                                        

                                        Also you may need to set group style sheet to move text to the top of group frame. I do use it. Otherwise, the title text may push the radio buttons out of the group frame. Set minimum height to your group box.
                                        If you do not want to set border properties, it is OK. But it is better to set margin top which is related to your group font size. Play with font size and parameter 1.6 and you will be able to move the radio buttons into the group frame.

                                        1 Reply Last reply
                                        0
                                        • JoeCFDJ JoeCFD

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

                                          QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
                                          
                                          QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
                                          QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
                                          QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
                                          
                                          radio1->setChecked(true);
                                          QVBoxLayout *vbox = new QVBoxLayout;
                                          vbox->addWidget(radio1);
                                          vbox->addWidget(radio2);
                                          vbox->addWidget(radio3);
                                          vbox->addStretch(1);
                                          groupBox->setLayout(vbox);
                                          
                                          return groupBox;
                                          
                                              auto groupBox = new QGroupBox(tr("Exclusive Radio Buttons"), this );
                                          
                                              auto radio1 = new QRadioButton(tr("&Radio button 1"), groupBox);
                                              auto radio2 = new QRadioButton(tr("R&adio button 2"), groupBox);
                                              auto radio3 = new QRadioButton(tr("Ra&dio button 3"), groupBox);
                                          
                                              auto button_group = new QButtonGroup;
                                              button_group->addButton(radio1) ; 
                                              button_group->addButton(radio2) ;
                                              button_group->addButton(radio3) ;
                                              button_group->setExclusive( true );
                                              radio1->setChecked(true);
                                          
                                              auto vbox = new QVBoxLayout( groupBox );
                                              vbox->addWidget(radio1);
                                              vbox->addWidget(radio2);
                                              vbox->addWidget(radio3);
                                              vbox->addStretch(1);
                                          
                                              return groupBox;
                                          
                                          SPlattenS Offline
                                          SPlattenS Offline
                                          SPlatten
                                          wrote on last edited by SPlatten
                                          #21

                                          @JoeCFD, I'm not sure what you are demonstrating here? The section of code I pasted comes directly from the Qt link, also posted.

                                          What purpose does the QButtonGroup serve?

                                          I edited my XML and applied the style:

                                          <groupbox id="enSEX" eol="true" align="left" layout="vertical" 
                                          		  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>
                                          

                                          Here is the result:
                                          Screenshot 2021-10-18 at 20.37.30.png

                                          Kind Regards,
                                          Sy

                                          JoeCFDJ 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