Top level layout breaks desired form layout

  • I am having a strange problem. I'm trying to set up a dialog box using Qt 4.8 similar to one that I created under Qt 3. I'm using Qt Designer to set up the form. I get everything laid out, so that it looks like this:

    ! box before adding top level layout)!

    If I try to save the form at this point I get the error message

    This file contains top level spacers.
    They have NOT been saved into the form.

    Perhaps you forgot to create a layout?

    In order to avoid this message plus make sure the form resizes properly, I tried setting up a vertical layout at the top level. When I do this the form gets changed to look like this:

    ! box after applying top level layout)!

    Notice that not only are the various regions sized incorrectly, but the critical box, where the type of data set and the details associated with it, is no longer visible. It is behind the enlarged button bar. If I try to save this version I get the same error message as before, so something is going wrong in that regard as well. The ui file puts me over the posting limit, but I can mail it (or try to post only it) upon request.

    What am I doing wrong and how do I get the form to look the way I want it to? I was able to make this form before, but am obviously not understanding something in the transition from Qt 3 to Qt 4. I need to solve this before making the additional 15 forms associated with the program!

    Thank you,
    Dan Suson

  • I was able to fix this by creating a QWidget object that is the same size as the basic form and then putting all of my objects inside that widget. I'm not sure I understand why this is necessary, but it seems to work.

  • Hi djsuson,

    How to do the "creating a QWidget object" exactly? Is doing that in Qt Designer?

    Thanks in advance.

  • Hi djsuson,

    How to do the "creating a QWidget object" exactly? Is doing that in Qt Designer?

    Thanks in advance.

  • This happened to me and I had one spacer not joined in a layout with any other object. I just did a layout using it and the problem solved.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.