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 SGaist

    @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.

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

    @SGaist , if only I could show you the rest of my code, when I create any widget I pass the parent widget to the constructor that creates the new widget.

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • SPlattenS SPlatten

      @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

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

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

      QButtonGroup

      QButtonGroup serves making radio buttons exclusive. It is a common use. Otherwise, you need to handle them. Works for other buttons as well.
      Adding stylesheet with margin-top will help you move the radio buttons into the group box(set some minimum size to the groupbox to accomodate these buttons). I had the same problem as yours before. I solved the issue with stylesheet. Did you notice your title text("Exclusive Radio Buttons") does not show because it is inside the group box. The first radio button is there too.

      SPlattenS 1 Reply Last reply
      1
      • JoeCFDJ JoeCFD

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

        QButtonGroup

        QButtonGroup serves making radio buttons exclusive. It is a common use. Otherwise, you need to handle them. Works for other buttons as well.
        Adding stylesheet with margin-top will help you move the radio buttons into the group box(set some minimum size to the groupbox to accomodate these buttons). I had the same problem as yours before. I solved the issue with stylesheet. Did you notice your title text("Exclusive Radio Buttons") does not show because it is inside the group box. The first radio button is there too.

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

        @JoeCFD , thank you, so is this a Qt bug? as the link I posted before doesn't use QButtonGroup ?

        Kind Regards,
        Sy

        JoeCFDJ 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @JoeCFD , thank you, so is this a Qt bug? as the link I posted before doesn't use QButtonGroup ?

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

          @SPlatten It is true that that is a bug in the example. You copied it from there. If qbuttongroup is not used, you have to have a slot onButtonClicked to toggle them(messy). Sometimes, you may need it for your app.

          QButtonGroup is very helpful. Now you know how to use it.

          SPlattenS 1 Reply Last reply
          1
          • JoeCFDJ JoeCFD

            @SPlatten It is true that that is a bug in the example. You copied it from there. If qbuttongroup is not used, you have to have a slot onButtonClicked to toggle them(messy). Sometimes, you may need it for your app.

            QButtonGroup is very helpful. Now you know how to use it.

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

            @JoeCFD , I'll try to describe what I'm working on, I am developing an engine that reads the configuration of what will be contained in a window from an XML set of files. The XML can be edited and reloaded into the engine with no source code changes required, the engine renders the content of the XML file converting it to widgets, as an example:

            <?xml version="1.0" encoding="utf-8"?>
            <form title="Test form" id="frmTest" hspacing="0" vspacing="0" width="480"
            	  height="480" modal="false">
            	<entry control="listwidget" label="Select:" id="enSEL"
            		   cols="24" rows="1" mode="single" excludeFromChangeCheck="true"
            		   resetPropertiesOnChange="true" eol="true">
            		<subscriber signal="itemSelectionChanged" 
            					target="simon2.js@listWidgetHandler"/>		
            		<subscriber signal="currentItemChanged"
            					target="simon2.js@listWidgetChanged"/>		
            	</entry>
            	<entry control="lineedit" label="First name:" id="enFN" eol="true"
            		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcFirstName"/>
            	<entry control="lineedit" label="Surnname:" id="enSN" eol="true"
            		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcSurName"/>
            	<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>
            	<entry control="checkbox" label="Employed:" id="enEmp" eol="true"
            		  dbfield="intEmployed"/>
            	<entry control="textedit" label="Address:" id="enADR" eol="true"
            		   maxlength="256" accept="alpha_numeric" cols="24" rows="5"
            		   dbfield="vcAddress"/>
            	<groupbox id="enButtons" eol="true" align="right" layout="horizontal">		   
            		<button id="btnApply" api="applyChanges">
            			<subscriber signal="clicked" target="simon2.js@applyButton"/>
            		</button>
            		<button id="btnUndo" api="undoChanges"/>
            		<button id="btnOK" api="submitAndClose"/>	
            	</groupbox>			
            	<on saveChanges="Save changes before changing selection?"/>
            	<on setup="simon2.js@setupForm"/>
            </form>
            

            I'm still having problems in getting the layout and groupbox to work properly, now I am getting a problem where after setting the layout, the code jumps into QWidgetRepaintManager::removeDirtyWidget.

            This happens immediately after I call setLayout on the QGroupBox widget.

            Kind Regards,
            Sy

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

              Are you giving a parent to the layout before calling setLayout ?

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

              1 Reply Last reply
              0
              • SPlattenS SPlatten

                @JoeCFD , I'll try to describe what I'm working on, I am developing an engine that reads the configuration of what will be contained in a window from an XML set of files. The XML can be edited and reloaded into the engine with no source code changes required, the engine renders the content of the XML file converting it to widgets, as an example:

                <?xml version="1.0" encoding="utf-8"?>
                <form title="Test form" id="frmTest" hspacing="0" vspacing="0" width="480"
                	  height="480" modal="false">
                	<entry control="listwidget" label="Select:" id="enSEL"
                		   cols="24" rows="1" mode="single" excludeFromChangeCheck="true"
                		   resetPropertiesOnChange="true" eol="true">
                		<subscriber signal="itemSelectionChanged" 
                					target="simon2.js@listWidgetHandler"/>		
                		<subscriber signal="currentItemChanged"
                					target="simon2.js@listWidgetChanged"/>		
                	</entry>
                	<entry control="lineedit" label="First name:" id="enFN" eol="true"
                		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcFirstName"/>
                	<entry control="lineedit" label="Surnname:" id="enSN" eol="true"
                		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcSurName"/>
                	<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>
                	<entry control="checkbox" label="Employed:" id="enEmp" eol="true"
                		  dbfield="intEmployed"/>
                	<entry control="textedit" label="Address:" id="enADR" eol="true"
                		   maxlength="256" accept="alpha_numeric" cols="24" rows="5"
                		   dbfield="vcAddress"/>
                	<groupbox id="enButtons" eol="true" align="right" layout="horizontal">		   
                		<button id="btnApply" api="applyChanges">
                			<subscriber signal="clicked" target="simon2.js@applyButton"/>
                		</button>
                		<button id="btnUndo" api="undoChanges"/>
                		<button id="btnOK" api="submitAndClose"/>	
                	</groupbox>			
                	<on saveChanges="Save changes before changing selection?"/>
                	<on setup="simon2.js@setupForm"/>
                </form>
                

                I'm still having problems in getting the layout and groupbox to work properly, now I am getting a problem where after setting the layout, the code jumps into QWidgetRepaintManager::removeDirtyWidget.

                This happens immediately after I call setLayout on the QGroupBox widget.

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

                @SPlatten Good stuff. Can you please show your code for building layout? XML file has only properties of widgets and can not tell why layout goes wrong.

                A good practice for debugging is to keep a small GUI case with ui file generated from qt designer and then you compile this case. From ui_*** file created in build, you can see how widgets are laid out. In this way, you can save a lot of time. I believe your time worths some good money.

                SPlattenS 1 Reply Last reply
                2
                • JoeCFDJ JoeCFD

                  @SPlatten Good stuff. Can you please show your code for building layout? XML file has only properties of widgets and can not tell why layout goes wrong.

                  A good practice for debugging is to keep a small GUI case with ui file generated from qt designer and then you compile this case. From ui_*** file created in build, you can see how widgets are laid out. In this way, you can save a lot of time. I believe your time worths some good money.

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

                  @JoeCFD , the issue I have now is that I've created a mock up using Qt Creator and in this I added a QGroupBox, then into this I added a QVBoxLayout then added three QRadioButtons, I then examined the document as XML and everything looked fine, when I build and ran it also looked fine.

                  However I'm having difficulty replicating this, I have a QGroupBox, I've created a layout and used setLayout on the QGroupBox widget, so far so good....but now I want to set the parent to the layout but can't, because the layouts are not derived from QWidget and calling ->widget() on the layout returns nullptr. I want to use the layout like a widget so I can add other widgets to it using the layout as a parent.

                  Kind Regards,
                  Sy

                  jsulmJ 1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @JoeCFD , the issue I have now is that I've created a mock up using Qt Creator and in this I added a QGroupBox, then into this I added a QVBoxLayout then added three QRadioButtons, I then examined the document as XML and everything looked fine, when I build and ran it also looked fine.

                    However I'm having difficulty replicating this, I have a QGroupBox, I've created a layout and used setLayout on the QGroupBox widget, so far so good....but now I want to set the parent to the layout but can't, because the layouts are not derived from QWidget and calling ->widget() on the layout returns nullptr. I want to use the layout like a widget so I can add other widgets to it using the layout as a parent.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #30

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

                    I want to use the layout like a widget so I can add other widgets to it using the layout as a parent.

                    You can't. A layout is not QWidget. And I'm wondering why you want to do this? There is already a simple way to add a widget to a layout.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    SPlattenS 1 Reply Last reply
                    0
                    • jsulmJ jsulm

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

                      I want to use the layout like a widget so I can add other widgets to it using the layout as a parent.

                      You can't. A layout is not QWidget. And I'm wondering why you want to do this? There is already a simple way to add a widget to a layout.

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

                      @jsulm, I've tried implementing this:

                                  QLayout* pobjLayout(nullptr);
                                  if ( pobjParent != nullptr ) {
                          //Does the parent have a layout?
                                      pobjLayout = pobjParent->pobjGetLayout();
                                      if ( pobjLayout != nullptr ) {
                          //Yes, clear the pobjParWidget widget
                                          pobjParWidget = nullptr;
                                      }
                                  }
                                  pobjWidget = qobject_cast<QWidget*>(clsCNT::pCreate(this,
                                                                                      mstrName,
                                                                                      strCSS,
                                                                                      slstProperties,
                                                                                      pobjParWidget));
                                  if ( pobjLayout != nullptr ) {
                          //Add the widget to the layout
                                      pobjLayout->addWidget(pobjWidget);                
                                  }
                      

                      However this doesn't work either, the radio buttons still appear outside of the groupbox and not in the layout, I've single stepped the logic, so the radio button widgets are added to the layout.

                      Kind Regards,
                      Sy

                      jsulmJ 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @jsulm, I've tried implementing this:

                                    QLayout* pobjLayout(nullptr);
                                    if ( pobjParent != nullptr ) {
                            //Does the parent have a layout?
                                        pobjLayout = pobjParent->pobjGetLayout();
                                        if ( pobjLayout != nullptr ) {
                            //Yes, clear the pobjParWidget widget
                                            pobjParWidget = nullptr;
                                        }
                                    }
                                    pobjWidget = qobject_cast<QWidget*>(clsCNT::pCreate(this,
                                                                                        mstrName,
                                                                                        strCSS,
                                                                                        slstProperties,
                                                                                        pobjParWidget));
                                    if ( pobjLayout != nullptr ) {
                            //Add the widget to the layout
                                        pobjLayout->addWidget(pobjWidget);                
                                    }
                        

                        However this doesn't work either, the radio buttons still appear outside of the groupbox and not in the layout, I've single stepped the logic, so the radio button widgets are added to the layout.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #32

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

                        pobjLayout->addWidget(pobjWidget)

                        Is this line executed?
                        If it is: to which widget does this layout belong? What is pobjGetLayout() actually doing?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        SPlattenS 1 Reply Last reply
                        0
                        • jsulmJ jsulm

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

                          pobjLayout->addWidget(pobjWidget)

                          Is this line executed?
                          If it is: to which widget does this layout belong? What is pobjGetLayout() actually doing?

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

                          @jsulm , yes, it is. I've used setObjectName to assign the layouts and widgets the id's they have in the XML.

                          In the above pobjLayout points to a QVBoxLayout and pobjWidget points to a QRadioButton.

                          The layout is appended to a QGroupBox via setLayout.

                          Kind Regards,
                          Sy

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

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

                            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 );

                            override the style sheet of group box in the xml with
                            int margin_top = font().pointSize()* 1.6;
                            QString group_style_sheet = QString("QGroupBox{border: 2px solid gray;border-radius: 8px;margin-top: %1px;}" ).arg( margin_top );
                            You try to hardcode it and see if it works.

                            SPlattenS JoeCFDJ 2 Replies Last reply
                            0
                            • JoeCFDJ JoeCFD

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

                              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 );

                              override the style sheet of group box in the xml with
                              int margin_top = font().pointSize()* 1.6;
                              QString group_style_sheet = QString("QGroupBox{border: 2px solid gray;border-radius: 8px;margin-top: %1px;}" ).arg( margin_top );
                              You try to hardcode it and see if it works.

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

                              @JoeCFD , thank you appreciated, why isn't this kind of thing required when positioning and using Qt Creator? This is the XML copied from the UI file which works perfectly.

                                 <widget class="QGroupBox" name="groupBox">
                                  <property name="geometry">
                                   <rect>
                                    <x>120</x>
                                    <y>170</y>
                                    <width>301</width>
                                    <height>201</height>
                                   </rect>
                                  </property>
                                  <property name="title">
                                   <string>GroupBox</string>
                                  </property>
                                  <widget class="QWidget" name="verticalLayoutWidget">
                                   <property name="geometry">
                                    <rect>
                                     <x>9</x>
                                     <y>29</y>
                                     <width>291</width>
                                     <height>161</height>
                                    </rect>
                                   </property>
                                   <layout class="QVBoxLayout" name="verticalLayout">
                                    <item>
                                     <widget class="QRadioButton" name="Radio1">
                                      <property name="text">
                                       <string>Radio1</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QRadioButton" name="Radio2">
                                      <property name="text">
                                       <string>Radio2</string>
                                      </property>
                                     </widget>
                                    </item>
                                    <item>
                                     <widget class="QRadioButton" name="Radio3">
                                      <property name="text">
                                       <string>Radio3</string>
                                      </property>
                                     </widget>
                                    </item>
                                   </layout>
                                  </widget>
                                 </widget>
                                </widget>
                               </widget>
                              

                              No sign of any styles or positioning, I'm now trying to reverse the logic to see where the difference is.

                              This is what I found in the debugger looking at how the above XML appears:
                              Screenshot 2021-10-20 at 18.06.21.png
                              What I don't understand is what is **[0] "verticalLayout" as a child ?

                              Drill down a bit more into this layout:
                              Screenshot 2021-10-20 at 18.25.22.png
                              It appears that the groupBox has one child which I agree with and expect verticalLayoutWidget, the layout has 4 children which I didn't expect:

                              • verticalLayout
                              • Radio1
                              • Radio2
                              • Radio3

                              What is verticalLayout and where did it come from, it has no children, it isn't in the XML layout ?

                              Just to clarify, just in case the screenshot isn't clear it shows:

                              groupBox
                                  verticalLayout
                                      verticalLayoutWidget
                                      Radio1
                                      Radio2
                                      Radio3
                              

                              Its verticalLayoutWidget that is the mystery...

                              Another edit, looked again at the XML and it does match the debugger screenshot. It looks like there is a fiddle in that the first widget is not the QVBoxLayout but a Widget called "verticalLayoutWidget".

                              Kind Regards,
                              Sy

                              JoeCFDJ 1 Reply Last reply
                              0
                              • SPlattenS SPlatten

                                @JoeCFD , thank you appreciated, why isn't this kind of thing required when positioning and using Qt Creator? This is the XML copied from the UI file which works perfectly.

                                   <widget class="QGroupBox" name="groupBox">
                                    <property name="geometry">
                                     <rect>
                                      <x>120</x>
                                      <y>170</y>
                                      <width>301</width>
                                      <height>201</height>
                                     </rect>
                                    </property>
                                    <property name="title">
                                     <string>GroupBox</string>
                                    </property>
                                    <widget class="QWidget" name="verticalLayoutWidget">
                                     <property name="geometry">
                                      <rect>
                                       <x>9</x>
                                       <y>29</y>
                                       <width>291</width>
                                       <height>161</height>
                                      </rect>
                                     </property>
                                     <layout class="QVBoxLayout" name="verticalLayout">
                                      <item>
                                       <widget class="QRadioButton" name="Radio1">
                                        <property name="text">
                                         <string>Radio1</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QRadioButton" name="Radio2">
                                        <property name="text">
                                         <string>Radio2</string>
                                        </property>
                                       </widget>
                                      </item>
                                      <item>
                                       <widget class="QRadioButton" name="Radio3">
                                        <property name="text">
                                         <string>Radio3</string>
                                        </property>
                                       </widget>
                                      </item>
                                     </layout>
                                    </widget>
                                   </widget>
                                  </widget>
                                 </widget>
                                

                                No sign of any styles or positioning, I'm now trying to reverse the logic to see where the difference is.

                                This is what I found in the debugger looking at how the above XML appears:
                                Screenshot 2021-10-20 at 18.06.21.png
                                What I don't understand is what is **[0] "verticalLayout" as a child ?

                                Drill down a bit more into this layout:
                                Screenshot 2021-10-20 at 18.25.22.png
                                It appears that the groupBox has one child which I agree with and expect verticalLayoutWidget, the layout has 4 children which I didn't expect:

                                • verticalLayout
                                • Radio1
                                • Radio2
                                • Radio3

                                What is verticalLayout and where did it come from, it has no children, it isn't in the XML layout ?

                                Just to clarify, just in case the screenshot isn't clear it shows:

                                groupBox
                                    verticalLayout
                                        verticalLayoutWidget
                                        Radio1
                                        Radio2
                                        Radio3
                                

                                Its verticalLayoutWidget that is the mystery...

                                Another edit, looked again at the XML and it does match the debugger screenshot. It looks like there is a fiddle in that the first widget is not the QVBoxLayout but a Widget called "verticalLayoutWidget".

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

                                @SPlatten group box has a layout for three radio buttons and is a child as well. In total, it has 4 children.

                                SPlattenS 1 Reply Last reply
                                0
                                • JoeCFDJ JoeCFD

                                  @SPlatten group box has a layout for three radio buttons and is a child as well. In total, it has 4 children.

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

                                  @JoeCFD, please see edit, bit at the bottom.

                                  Kind Regards,
                                  Sy

                                  JoeCFDJ 1 Reply Last reply
                                  0
                                  • SPlattenS SPlatten

                                    @JoeCFD, please see edit, bit at the bottom.

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

                                    @SPlatten You created a verticalLayoutWidget inside a group box which has 4 children:
                                    verticalLayout
                                    radio1
                                    radio2
                                    radio3

                                    verticalLayoutWidget is not needed. the parent of verticalLayoutWidget is groupBox.

                                    SPlattenS 1 Reply Last reply
                                    0
                                    • JoeCFDJ JoeCFD

                                      @SPlatten You created a verticalLayoutWidget inside a group box which has 4 children:
                                      verticalLayout
                                      radio1
                                      radio2
                                      radio3

                                      verticalLayoutWidget is not needed. the parent of verticalLayoutWidget is groupBox.

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

                                      @JoeCFD , to repeat what I did:

                                      • 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

                                      Thats it, one layout not two. Take a look at the XML I posted, its pretty clear and its the actual elements that are generated from this XML that I'm questioning.

                                      Kind Regards,
                                      Sy

                                      1 Reply Last reply
                                      0
                                      • JoeCFDJ JoeCFD

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

                                        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 );

                                        override the style sheet of group box in the xml with
                                        int margin_top = font().pointSize()* 1.6;
                                        QString group_style_sheet = QString("QGroupBox{border: 2px solid gray;border-radius: 8px;margin-top: %1px;}" ).arg( margin_top );
                                        You try to hardcode it and see if it works.

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

                                        @JoeCFD
                                        if there is no title for the group, set top margin to 0
                                        QString group_style_sheet = QString("QGroupBox{border: 2px solid gray;border-radius: 8px;margin-top: 0px;}" );

                                        SPlattenS 1 Reply Last reply
                                        0
                                        • JoeCFDJ JoeCFD

                                          @JoeCFD
                                          if there is no title for the group, set top margin to 0
                                          QString group_style_sheet = QString("QGroupBox{border: 2px solid gray;border-radius: 8px;margin-top: 0px;}" );

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

                                          @JoeCFD , but why? What I'm trying to understand is why if done in Qt Creator WYSIWYG, no fiddles are required and it works, but the code generated from the XML just doesn't add up.

                                          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