PDA

View Full Version : Why does Designer alter my UI upon Save/Load?



ZB
17th September 2006, 13:12
I have been using Designer for a few days and notice that upon saving an interface, Designer will replace all my layouts with widgets and start malfunctioning.


What I am doing:

I create a new main window form, place a square frame and beneath it two small tool buttons both of the same minimum and maximum size to prevent them from resizing, I also put a horizontal sizer next to them. I mark all four widgets and put them in a grid layout and change its spacing to 0 to pack the widgets neatly together.

At this point everything is fine, I can see the red frame of the layout and it will move and resize the widgets within as expected. I then save the form, quit Designer, start it up again and load the form.

Now, looking in the object inspector window, what used to be my "<noname> QGridlayout" has now been replaced by a "Widget QWidget", still grouping my widgets inside and functioning as a grid layout, however it is not displaying its red frame and I am not able to break the layout. If I delete this new grouping widget and its children, its layout effect will sometimes persist, and creating a new widget in the main window will make it size and position as if the entire window itself was a grid layout, eventhough I did not perform that step.


How do I resolve this? I am using the precompiled Qt Designer in the 4.1.4 Open Source package under Windows XP SP2.

jpn
17th September 2006, 22:06
You can't leave layouts floating around. This was even more strictly prevented in earlier designer versions. It was impossible to save a form which had floating layouts. The behaviour was changed recently. Nowadays a wrapper widget is created just to set the floating layout to.

Try setting a top level layout for the designed form instead of just selecting those 4 particular widgets and layouting them into a floating layout. A top level layout can be set for example through the context menu from main window's background ("Lay out" -> "Lay Out in a grid").

ZB
17th September 2006, 23:30
Thanks, I found this solution too.

I hope the Qt team will change this since not performing these steps stops you from conveniently saving your UI for working at it at a later time. Forgetting to do this leaves you with no choice but picking the contained widgets and moving them outside manually and "re-layouting" it all again, since you can't break the grouping widget or "empty" it of controls, which also would be a very useful function.

Thanks

jacek
17th September 2006, 23:46
http://www.trolltech.com/developer/task-tracker/index_html?method=entry&id=123587

wysota
18th September 2006, 00:13
Thanks, I found this solution too.

I hope the Qt team will change this since not performing these steps stops you from conveniently saving your UI for working at it at a later time.

On the other hand, if the layout was left "floating", it would produce an invalid file (and I guess it is good if a graphical editor produces only valid files). An easy (and probably good) solution is to always use a top level layout. The truth is -- if you don't use a top level layout, you don't need lower level layouts, so it might be a good idea to just get rid of one of the floating layouts in favour of the top level layout. And using a top level layout even if you're not done with adding widgets yet doesn't cost you anything - you can always break the layout later.