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. Vertical spacer doesn't work after latest update
Forum Updated to NodeBB v4.3 + New Features

Vertical spacer doesn't work after latest update

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 6 Posters 2.0k Views 1 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.
  • Ali-SZA Offline
    Ali-SZA Offline
    Ali-SZ
    wrote on last edited by
    #1

    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:
    Screenshot from 2024-08-05 15-55-37.png Screenshot from 2024-08-05 15-56-04.png

    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.

    JonBJ 1 Reply Last reply
    0
    • Ali-SZA Ali-SZ

      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:
      Screenshot from 2024-08-05 15-55-37.png Screenshot from 2024-08-05 15-56-04.png

      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.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Ali-SZ
      Is the code you show generated in the .ui file the same as it used to be? What about the same in generated _ui.h? If so the issue has nothing to do with the .ui, Creator or even uic.

      1 Reply Last reply
      0
      • Ali-SZA Offline
        Ali-SZA Offline
        Ali-SZ
        wrote on last edited by Ali-SZ
        #3

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

        JonBJ 1 Reply Last reply
        0
        • Ali-SZA Ali-SZ

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

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @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 replaced Qt::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-SZA 1 Reply Last reply
          0
          • JonBJ JonB

            @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 replaced Qt::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-SZA Offline
            Ali-SZA Offline
            Ali-SZ
            wrote on last edited by
            #5

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

            JonBJ 1 Reply Last reply
            0
            • Ali-SZA Ali-SZ

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

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @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 generated ui_....h files have it reversed you have an error in uic 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.

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                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
                2
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  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 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
                  2
                  • F Offline
                    F Offline
                    friedemannkleint
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    2
                    • Ali-SZA Offline
                      Ali-SZA Offline
                      Ali-SZ
                      wrote on last edited by
                      #10

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

                      JonBJ 1 Reply Last reply
                      0
                      • Ali-SZA Ali-SZ

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

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by JonB
                        #11

                        @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 in ui_....h to see how you can access the variable for the spacer, I think it will be ui->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 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.

                        Ali-SZA L 2 Replies Last reply
                        1
                        • JonBJ JonB

                          @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 in ui_....h to see how you can access the variable for the spacer, I think it will be ui->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 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.

                          Ali-SZA Offline
                          Ali-SZA Offline
                          Ali-SZ
                          wrote on last edited by
                          #12

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

                          1 Reply Last reply
                          1
                          • Ali-SZA Ali-SZ has marked this topic as solved on
                          • JonBJ JonB

                            @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 in ui_....h to see how you can access the variable for the spacer, I think it will be ui->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 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.

                            L Offline
                            L Offline
                            legerborea
                            wrote on last edited by
                            #13

                            @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

                            jsulmJ 1 Reply Last reply
                            0
                            • L legerborea

                              @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

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

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

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              L 1 Reply Last reply
                              1
                              • jsulmJ jsulm

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

                                L Offline
                                L Offline
                                legerborea
                                wrote on last edited by
                                #15

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

                                Capture d’écran du 2024-09-17 10-36-39.png

                                jsulmJ 1 Reply Last reply
                                0
                                • L legerborea

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

                                  Capture d’écran du 2024-09-17 10-36-39.png

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @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

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  L 1 Reply Last reply
                                  1
                                  • jsulmJ jsulm

                                    @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

                                    L Offline
                                    L Offline
                                    legerborea
                                    wrote on last edited by
                                    #17

                                    @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 :)

                                    1 Reply Last reply
                                    1

                                    • Login

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