Nominate our 2022 Qt Champions!

Somehow the layout got messed up in Qt Creator. Hints?

  • Hi,

    for some reason the layout of my little program got all but messed up after I played around with the layout of the central widget and then reverted the changes. I guess there are code remains left in the .ui file, but I'm not sure, what I should do now. Maybe I should remove all layouts step by step. So any hint would be appreciated.

    Kind regards,


  • Lifetime Qt Champion

    @andi456 A version control system like Git is very helpful in such situations :-)
    Did you try to simply undo your changes (Ctrl-Z)?

  • Well, other problems prevented this approach because of which I had to restart Qt Creator. (Keyboard shortcuts not working anymore for some unknown reason...) There must be some code left that is being compiled without my permission.

    mainwindow.ui contains the following lines about a layout that is not accessible in visual mode:

      <widget class="QWidget" name="centralwidget">
       <widget class="QWidget" name="layoutWidget">
        <property name="geometry">

  • @andi456 Have you try "break layout" ?
    No need for git , just make another copy of your full layout before you start moving / removing stuff. Also if possible "group" your widgets in sort of puzzle style blocks. . It gets little more manageable - I look at that as a "comments" in code , it looks cluttered but stuff can be easy to move around in case of mishap.

  • Yes I broke up the layout of the central widget, but it didn't really work and messed up the whole layout.

  • @andi456 That is pretty "normal" - loosing the layout. As long as you have the "piece parts" you can put it back together.
    Does the project still compile / build? Would it help to post the form here ?

  • Well, I started from scratch, as I can use the old code. But, what do you mean by "puzzle style blocks"? The way I want to proceed is by grouping together those widgets that belong together (a label and a lineedit for example) in a horizontal or vertical layout and put those layouts in a group layout. This time I will make a backup of the .ui file before I experiment with the layout of the central widget....

Log in to reply