QGroupBox discrepancies between Linux and Win
-
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 -
Hi,
What exact OS are you talking about ?
What version of Qt are you using ? -
Can you provide a complete minimal project along your ui file ?
That will allow to test in the exact same conditions as you have. -
@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? -
@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.
- Make a copy of your full project.
- In the copied project, start removing big chunks of code and UI components that are not related to your issue.
- After you have removed a big chunk of code or UI, build and run the reduced code.
- 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.
-
@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?
-
@JonB Yes, the alignment of the groupbox label is defined by the style.
-
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.
-
@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#define
s for this, or if necessary you could make yourqmake
file pass a-D ...
for this.