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

QGroupBox discrepancies between Linux and Win

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 1.4k Views 2 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.
  • W Offline
    W Offline
    willemf
    wrote on 14 Nov 2019, 07:50 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 J 2 Replies Last reply 14 Nov 2019, 07:53
    0
    • W willemf
      14 Nov 2019, 07:50

      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 14 Nov 2019, 07:53 last edited by
      #2

      Windows.png
      Linux.png

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 14 Nov 2019, 20:16 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 15 Nov 2019, 11:19 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 15 Nov 2019, 11:20 last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Nov 2019, 22:49 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 16 Nov 2019, 07:45
              1
              • S SGaist
                15 Nov 2019, 22:49

                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 16 Nov 2019, 07:45 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?

                J 1 Reply Last reply 16 Nov 2019, 08:13
                0
                • W willemf
                  16 Nov 2019, 07:45

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

                  J Offline
                  J Offline
                  JKSH
                  Moderators
                  wrote on 16 Nov 2019, 08:13 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
                    14 Nov 2019, 07:50

                    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

                    J Online
                    J Online
                    JonB
                    wrote on 16 Nov 2019, 11:22 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?

                    C 1 Reply Last reply 16 Nov 2019, 11:33
                    2
                    • J JonB
                      16 Nov 2019, 11:22

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

                      C Offline
                      C Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 16 Nov 2019, 11:33 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 18 Nov 2019, 05:07 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.

                        J 1 Reply Last reply 18 Nov 2019, 07:43
                        0
                        • W willemf
                          18 Nov 2019, 05:07

                          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.

                          J Online
                          J Online
                          JonB
                          wrote on 18 Nov 2019, 07:43 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
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 18 Nov 2019, 18:01 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 20 Nov 2019, 11:47
                            1
                            • S SGaist
                              18 Nov 2019, 18:01

                              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 20 Nov 2019, 11:47 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

                              7/14

                              16 Nov 2019, 07:45

                              • Login

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