Vertical spacer doesn't work after latest update
-
I use Ubuntu 20.04 and just updated Qt Creator and sdk yesterday and after that vertical spacers in my projects doesn't work correctly but in designer it looks fine.
.ui file:
<spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> </size> </property> </spacer>
generated _ui.h file:
QSpacerItem *verticalSpacer_4; verticalSpacer_4 = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum); MainScreenMenuBar->addItem(verticalSpacer_4);
designer and built view:
I also tested in new projects with Qt5 and Qt6 but the results were still same and disabling style didn't change anything.
Only change was in .pro file, i added "QMAKE_CFLAGS_ISYSTEM = -I " because i got "stdlib.h: No such file or directory" from compiler and it does not build the project without it.
-
I use Ubuntu 20.04 and just updated Qt Creator and sdk yesterday and after that vertical spacers in my projects doesn't work correctly but in designer it looks fine.
.ui file:
<spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> </size> </property> </spacer>
generated _ui.h file:
QSpacerItem *verticalSpacer_4; verticalSpacer_4 = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum); MainScreenMenuBar->addItem(verticalSpacer_4);
designer and built view:
I also tested in new projects with Qt5 and Qt6 but the results were still same and disabling style didn't change anything.
Only change was in .pro file, i added "QMAKE_CFLAGS_ISYSTEM = -I " because i got "stdlib.h: No such file or directory" from compiler and it does not build the project without it.
-
@JonB
I checked the previous .ui file and it has changed:<spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer>
I added new vertical spacer for test and designer added spacer with "<enum>Qt::Orientation::Vertical</enum>" instead of "<enum>Qt::Vertical</enum>" as it used to be.
-
@JonB
I checked the previous .ui file and it has changed:<spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer>
I added new vertical spacer for test and designer added spacer with "<enum>Qt::Orientation::Vertical</enum>" instead of "<enum>Qt::Vertical</enum>" as it used to be.
@Ali-SZ
You said you changed something but did not say if it made any difference?I am not sure whether this is relevant. Creator has been updated to generate for newer Qt6,
Qt::Orientation::Vertical
has replacedQt::Vertical
. But I think either works for Qt5.Now compare generated
ui_....h
file, that's all that really matters. If that is about the only difference, and if it compiles OK, that is not your issue.In Ubuntu 20.04 are you using the Qt5 supplied with it? Or are you using your own compiled Qt5 or Qt6? I suspect you are still on Qt5? I don't know whether Creator/
uic
generate for Qt6, Qt5 or both.Other than this I don't know, maybe someone else knows what is going on.
-
@Ali-SZ
You said you changed something but did not say if it made any difference?I am not sure whether this is relevant. Creator has been updated to generate for newer Qt6,
Qt::Orientation::Vertical
has replacedQt::Vertical
. But I think either works for Qt5.Now compare generated
ui_....h
file, that's all that really matters. If that is about the only difference, and if it compiles OK, that is not your issue.In Ubuntu 20.04 are you using the Qt5 supplied with it? Or are you using your own compiled Qt5 or Qt6? I suspect you are still on Qt5? I don't know whether Creator/
uic
generate for Qt6, Qt5 or both.Other than this I don't know, maybe someone else knows what is going on.
@JonB
I did checkout to my previous commit and build the project and that commit doesn't had this issue so i checked the ui_....h file from the build and the changed line was this:verticalSpacer_4 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
both QSizePolicy values in function's arguments were swapped.
Only change i did in the project was changing the .ui file, i removed the spacer and built it, then ctrl+z the change and built it again for debugging after this issue happened to me after Qt Creator and sdk update.
I use official installed Qt kits in /home/user/Qt for both Qt5 and Qt6 versions, 5.15.0 for Qt5 and 6.5.2 for Qt6. the codes and images i sent was from Qt5 kit.
-
@JonB
I did checkout to my previous commit and build the project and that commit doesn't had this issue so i checked the ui_....h file from the build and the changed line was this:verticalSpacer_4 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
both QSizePolicy values in function's arguments were swapped.
Only change i did in the project was changing the .ui file, i removed the spacer and built it, then ctrl+z the change and built it again for debugging after this issue happened to me after Qt Creator and sdk update.
I use official installed Qt kits in /home/user/Qt for both Qt5 and Qt6 versions, 5.15.0 for Qt5 and 6.5.2 for Qt6. the codes and images i sent was from Qt5 kit.
@Ali-SZ
As you will understand I am a little lost on all the combinations, you have it in front of you. I believe you are suggesting you put in vertical spacer but seem to get the output for a horizontal one, or vice versa.- Make 100% sure you are placing the right kind of spacer in Creator/Designer!
- If the output in the saved
.ui
is reversed between Qt5 & 6 you have a Creator/Designer change/error. - If the
.ui
files are both correct but the generatedui_....h
files have it reversed you have an error inuic
between Qt5 & 6.
If you don't get an answer here you may have to raise a Qt bug report, preferably clearly showing which area the bad situation is in.
-
See https://forum.qt.io/topic/157569 and the according bug report here: https://bugreports.qt.io/browse/QTBUG-126966
@cristian-adam: Qt designer or QtCreator problem? Can't test it - no compilable Qt designer here atm.
-
Currently you can not use a Qt designer (or QtCreator) built with Qt6.7 or higher to modify a ui file which should be used with Qt5.
-
Qt Designer 6.7 writes fully qualified enumeration values to support scoped enums and Qt for Python (see https://lists.qt-project.org/pipermail/development/2023-November/044620.html ). This is supported in 6.6/6.5.4/6.2.13.
We got several reports that Qt Widgets Designer 6 was used to generate forms for 5.15, so we added support in 5.15.18 . Nevertheless, this is not supported and works by coincidence at best; widget properties and signal/slot names have changed in Qt 6.
-
@JonB @Christian-Ehrlicher @friedemannkleint
First thank you for help and i apologise if i made any confusion.So i updated Qt6 to 6.7.2 and Qt5 to 5.15.2 and created fresh Qt6 and Qt5 projects for test, the issue with Qt6 is gone but i still have this issue for Qt5.
For Qt5, i realised changing following code in generated ui_....h file:verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
to this:
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
Will fix the issue.
-
@JonB @Christian-Ehrlicher @friedemannkleint
First thank you for help and i apologise if i made any confusion.So i updated Qt6 to 6.7.2 and Qt5 to 5.15.2 and created fresh Qt6 and Qt5 projects for test, the issue with Qt6 is gone but i still have this issue for Qt5.
For Qt5, i realised changing following code in generated ui_....h file:verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
to this:
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
Will fix the issue.
@Ali-SZ said in Vertical spacer doesn't work after latest update:
For Qt5, i realised changing following code in generated ui_....h file:
Yes, but you have a problem: the
ui_....h
file is regenerated/overwritten any/every time you make any change to the.ui
file, or if if you rebuild from clean. Sooner or later this is going to bite you on your bottom!I think you have been told that you should not be using that version of Designer for Qt5. You should consider this carefully, as there may (well) be other items which will "go wrong" but may be hard to spot.
If you are determined to continue with a recent version of Creator even for an old Qt5. I would look at leaving whatever line is generated into
ui_....h
file as-is, because of regeneration. Have a look inui_....h
to see how you can access the variable for the spacer, I think it will beui->verticalSpacer
if you have named the widget.Now immediately after the call in your code to
setupUi()
append code to change it to whatever is needed for Qt5. You might do that at compile-time with a hard-coded replacement by enclosing inside some#ifdef Qt5 ... #endif
or at runtime via someif (qt_version() == Qt5)
. In the latter case you could read the current spacer size policy properties and set them back in swapped order: this could be used if you have other spacers which need changing. I think either of these approaches can be done, you'll have to search docs or ask for the correct symbol/function/variable to use for these tests. -
@Ali-SZ said in Vertical spacer doesn't work after latest update:
For Qt5, i realised changing following code in generated ui_....h file:
Yes, but you have a problem: the
ui_....h
file is regenerated/overwritten any/every time you make any change to the.ui
file, or if if you rebuild from clean. Sooner or later this is going to bite you on your bottom!I think you have been told that you should not be using that version of Designer for Qt5. You should consider this carefully, as there may (well) be other items which will "go wrong" but may be hard to spot.
If you are determined to continue with a recent version of Creator even for an old Qt5. I would look at leaving whatever line is generated into
ui_....h
file as-is, because of regeneration. Have a look inui_....h
to see how you can access the variable for the spacer, I think it will beui->verticalSpacer
if you have named the widget.Now immediately after the call in your code to
setupUi()
append code to change it to whatever is needed for Qt5. You might do that at compile-time with a hard-coded replacement by enclosing inside some#ifdef Qt5 ... #endif
or at runtime via someif (qt_version() == Qt5)
. In the latter case you could read the current spacer size policy properties and set them back in swapped order: this could be used if you have other spacers which need changing. I think either of these approaches can be done, you'll have to search docs or ask for the correct symbol/function/variable to use for these tests.@JonB said in Vertical spacer doesn't work after latest update:
Now immediately after the call in your code to setupUi() append code to change it to whatever is needed for Qt5. You might do that at compile-time with a hard-coded replacement by enclosing inside some #ifdef Qt5 ... #endif or at runtime via some if (qt_version() == Qt5). In the latter case you could read the current spacer size policy properties and set them back in swapped order: this could be used if you have other spacers which need changing. I think either of these approaches can be done, you'll have to search docs or ask for the correct symbol/function/variable to use for these tests.
Thank you, this solves the issue for now.
-
A Ali-SZ has marked this topic as solved on
-
@Ali-SZ said in Vertical spacer doesn't work after latest update:
For Qt5, i realised changing following code in generated ui_....h file:
Yes, but you have a problem: the
ui_....h
file is regenerated/overwritten any/every time you make any change to the.ui
file, or if if you rebuild from clean. Sooner or later this is going to bite you on your bottom!I think you have been told that you should not be using that version of Designer for Qt5. You should consider this carefully, as there may (well) be other items which will "go wrong" but may be hard to spot.
If you are determined to continue with a recent version of Creator even for an old Qt5. I would look at leaving whatever line is generated into
ui_....h
file as-is, because of regeneration. Have a look inui_....h
to see how you can access the variable for the spacer, I think it will beui->verticalSpacer
if you have named the widget.Now immediately after the call in your code to
setupUi()
append code to change it to whatever is needed for Qt5. You might do that at compile-time with a hard-coded replacement by enclosing inside some#ifdef Qt5 ... #endif
or at runtime via someif (qt_version() == Qt5)
. In the latter case you could read the current spacer size policy properties and set them back in swapped order: this could be used if you have other spacers which need changing. I think either of these approaches can be done, you'll have to search docs or ask for the correct symbol/function/variable to use for these tests.@JonB Hello,
You said to not use this version of the Designer for Qt5 projects but how do we go back to a previous QtCreator version ? (I have the exact same issue, designer view is fine but once built, spacer doesn't behave the same)
Qt MaintenanceTool doesn't provide a way to go back to a previous version and I can't find a parameter to set the designer version... (We are still stuck to Qt5.15 due to missing features in the Qt6 version)Any help will be appreciated
-
@JonB Hello,
You said to not use this version of the Designer for Qt5 projects but how do we go back to a previous QtCreator version ? (I have the exact same issue, designer view is fine but once built, spacer doesn't behave the same)
Qt MaintenanceTool doesn't provide a way to go back to a previous version and I can't find a parameter to set the designer version... (We are still stuck to Qt5.15 due to missing features in the Qt6 version)Any help will be appreciated
@legerborea said in Vertical spacer doesn't work after latest update:
Qt MaintenanceTool doesn't provide a way to go back to a previous version
There should be "Archive" check boy (not sure what exact text is shown there) to activate older versions.
But you can also download from https://download.qt.io/archive/qtcreator/ -
@legerborea said in Vertical spacer doesn't work after latest update:
Qt MaintenanceTool doesn't provide a way to go back to a previous version
There should be "Archive" check boy (not sure what exact text is shown there) to activate older versions.
But you can also download from https://download.qt.io/archive/qtcreator/@jsulm Hello, thank you for your answer, I have tried the checkbox "archives" but this only allow for old "kits", not old "qt creator" versions (see picture below).
I will try to build it from sources from the link you gave me, thank you. -
@jsulm Hello, thank you for your answer, I have tried the checkbox "archives" but this only allow for old "kits", not old "qt creator" versions (see picture below).
I will try to build it from sources from the link you gave me, thank you.@legerborea said in Vertical spacer doesn't work after latest update:
I will try to build it from sources from the link you gave me
You don't have to build from source - there are also binaries for Windows, Linux and MacOS
-
@legerborea said in Vertical spacer doesn't work after latest update:
I will try to build it from sources from the link you gave me
You don't have to build from source - there are also binaries for Windows, Linux and MacOS
@jsulm Thank you, I didn't want to run the installer, simply start a "standalone" version (to not break Qt Creator installed from Qt Maintenance Tool still useful for Qt 6 projects), so I used this one : https://download.qt.io/official_releases/qtcreator/13.0/13.0.2/installer_source/linux_x64/
Thank you for your help, this fixed my issue, I can continue to maintain 5.15.x projects :)