Vertical spacer doesn't work after latest update
-
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 :)