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. QGroupBox discrepancies between Linux and Win

QGroupBox discrepancies between Linux and Win

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 1.3k 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.
  • W Offline
    W Offline
    willemf
    wrote on last edited by
    #1

    Attached two screenshots of a screen layout for part of an application that is intended fro Linux as well as for Windows. The titles for the QGroupBoxes are shown in different places. Normally one would position the title by setting the top-margin using CSS. In this case NO top-margin has been defined at all. Attached a code snippet defining one of the QGroupBoxes.

           <item row="1" column="1">
            <widget class="QGroupBox" name="groupBox_12">
             <property name="title">
              <string>Interval</string>
             </property>
             <property name="alignment">
              <set>Qt::AlignHCenter</set>
             </property>
             <property name="sizePolicy">
              <sizepolicy hsizetype="Ignored" vsizetype="Preferred">
               <horstretch>1</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <layout class="QHBoxLayout" name="diveInfoSurfintervallLayout">
              <item>
               <widget class="QLabel" name="surfaceIntervalText">
                <property name="text">
                 <string/>
                </property>
                <property name="alignment">
                 <set>Qt::AlignHCenter</set>
                </property>
               </widget>
              </item>
             </layout>
            </widget>
           </item>
    
    

    In this case the only CSS that has been added was that setting the colour of the headings.

    ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox::title { color: mediumblue;} ");
    

    Is this between-OS difference known?
    Could it result from differences between different versions of Qt?
    Kind regards,
    Willem Ferguson

    W JonBJ 2 Replies Last reply
    0
    • W willemf

      Attached two screenshots of a screen layout for part of an application that is intended fro Linux as well as for Windows. The titles for the QGroupBoxes are shown in different places. Normally one would position the title by setting the top-margin using CSS. In this case NO top-margin has been defined at all. Attached a code snippet defining one of the QGroupBoxes.

             <item row="1" column="1">
              <widget class="QGroupBox" name="groupBox_12">
               <property name="title">
                <string>Interval</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignHCenter</set>
               </property>
               <property name="sizePolicy">
                <sizepolicy hsizetype="Ignored" vsizetype="Preferred">
                 <horstretch>1</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <layout class="QHBoxLayout" name="diveInfoSurfintervallLayout">
                <item>
                 <widget class="QLabel" name="surfaceIntervalText">
                  <property name="text">
                   <string/>
                  </property>
                  <property name="alignment">
                   <set>Qt::AlignHCenter</set>
                  </property>
                 </widget>
                </item>
               </layout>
              </widget>
             </item>
      
      

      In this case the only CSS that has been added was that setting the colour of the headings.

      ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox::title { color: mediumblue;} ");
      

      Is this between-OS difference known?
      Could it result from differences between different versions of Qt?
      Kind regards,
      Willem Ferguson

      W Offline
      W Offline
      willemf
      wrote on last edited by
      #2

      Windows.png
      Linux.png

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

        Hi,

        What exact OS are you talking about ?
        What version of Qt are you using ?

        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
        • W Offline
          W Offline
          willemf
          wrote on last edited by
          #4

          Ubuntu 18.04 LTS
          I tested with Qt5.9 and Qt5.12
          Kind regards,
          willem

          1 Reply Last reply
          0
          • W Offline
            W Offline
            willemf
            wrote on last edited by
            #5

            Apologies. And Windows 7 as well as Windows 10.
            Kind regards,
            willem

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

              Can you provide a complete minimal project along your ui file ?
              That will allow to test in the exact same conditions as you have.

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

              W 1 Reply Last reply
              1
              • SGaistS SGaist

                Can you provide a complete minimal project along your ui file ?
                That will allow to test in the exact same conditions as you have.

                W Offline
                W Offline
                willemf
                wrote on last edited by
                #7

                @SGaist
                Thank you for your time! This is part of a larger project and I have no idea of how to scale it down into a minimal project. I do the layout in a .ui file which started in QtCreator but I hand-edit the .ui file by hand these days. Would it help at all if I send you the complete .ui file?

                JKSHJ 1 Reply Last reply
                0
                • W willemf

                  @SGaist
                  Thank you for your time! This is part of a larger project and I have no idea of how to scale it down into a minimal project. I do the layout in a .ui file which started in QtCreator but I hand-edit the .ui file by hand these days. Would it help at all if I send you the complete .ui file?

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

                  @willemf said in QGroupBox discrepancies between Linux and Win:

                  This is part of a larger project and I have no idea of how to scale it down into a minimal project.

                  1. Make a copy of your full project.
                  2. In the copied project, start removing big chunks of code and UI components that are not related to your issue.
                  3. After you have removed a big chunk of code or UI, build and run the reduced code.
                  4. Repeat steps #2 and #3 until the problem disappears, or until your project is tiny.

                  If the problem disappears, examine the last thing that you removed.

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

                  1 Reply Last reply
                  0
                  • W willemf

                    Attached two screenshots of a screen layout for part of an application that is intended fro Linux as well as for Windows. The titles for the QGroupBoxes are shown in different places. Normally one would position the title by setting the top-margin using CSS. In this case NO top-margin has been defined at all. Attached a code snippet defining one of the QGroupBoxes.

                           <item row="1" column="1">
                            <widget class="QGroupBox" name="groupBox_12">
                             <property name="title">
                              <string>Interval</string>
                             </property>
                             <property name="alignment">
                              <set>Qt::AlignHCenter</set>
                             </property>
                             <property name="sizePolicy">
                              <sizepolicy hsizetype="Ignored" vsizetype="Preferred">
                               <horstretch>1</horstretch>
                               <verstretch>0</verstretch>
                              </sizepolicy>
                             </property>
                             <layout class="QHBoxLayout" name="diveInfoSurfintervallLayout">
                              <item>
                               <widget class="QLabel" name="surfaceIntervalText">
                                <property name="text">
                                 <string/>
                                </property>
                                <property name="alignment">
                                 <set>Qt::AlignHCenter</set>
                                </property>
                               </widget>
                              </item>
                             </layout>
                            </widget>
                           </item>
                    
                    

                    In this case the only CSS that has been added was that setting the colour of the headings.

                    ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox::title { color: mediumblue;} ");
                    

                    Is this between-OS difference known?
                    Could it result from differences between different versions of Qt?
                    Kind regards,
                    Willem Ferguson

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

                    @willemf
                    Something like https://stackoverflow.com/questions/37233885/qt-style-windows-vs-xubuntu-gtk-no-border-in-qgropbox makes clear there are/can be differences between OS/window managers. Also that there can be deliberate "native" style differences.

                    One thing to check is that you are indeed using the same style? And/or, does the difference persist if you try other styles?

                    Christian EhrlicherC 1 Reply Last reply
                    2
                    • JonBJ JonB

                      @willemf
                      Something like https://stackoverflow.com/questions/37233885/qt-style-windows-vs-xubuntu-gtk-no-border-in-qgropbox makes clear there are/can be differences between OS/window managers. Also that there can be deliberate "native" style differences.

                      One thing to check is that you are indeed using the same style? And/or, does the difference persist if you try other styles?

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @JonB Yes, the alignment of the groupbox label is defined by the style.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        willemf
                        wrote on last edited by
                        #11

                        Thank you very much for your responses. This explains the issue that I have been having and, fortunately, I do not have to create scaled-down minimum code for testing. I would like to explore the possibility of doing platform-dependent modification of the code by using CSS styles. I have looked everywhere but I cannot find an environmental variable within Qt that reflects the platform being used. Does anything like that exist at all? Thank you again for your time.

                        JonBJ 1 Reply Last reply
                        0
                        • W willemf

                          Thank you very much for your responses. This explains the issue that I have been having and, fortunately, I do not have to create scaled-down minimum code for testing. I would like to explore the possibility of doing platform-dependent modification of the code by using CSS styles. I have looked everywhere but I cannot find an environmental variable within Qt that reflects the platform being used. Does anything like that exist at all? Thank you again for your time.

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

                          @willemf
                          There won't be a run-time environment variable. I don't know of any Qt-something to indicate what platform you are on, and the platform-specific calls to determine this won't help as they are platform-specific! However, you know at compile-time which platform you are compiling for, there should be compile-time #defines for this, or if necessary you could make your qmake file pass a -D ... for this.

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

                            At compile time you have the various Q_OS_XXX that allows you to encapsulate code for a specific platform.

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

                            W 1 Reply Last reply
                            1
                            • SGaistS SGaist

                              At compile time you have the various Q_OS_XXX that allows you to encapsulate code for a specific platform.

                              W Offline
                              W Offline
                              willemf
                              wrote on last edited by
                              #14

                              @SGaist that completely answers my question. I thank you for your time in answering this.
                              Kind regards,
                              willem

                              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