PDA

View Full Version : Proper way of using Designer for MainWindows



Doug Broadwell
11th October 2006, 01:56
I have created a test main window in Designer and place a bunch of UI elements in it. In struggling to get it working I find that the documentation states that you should not place a layout on the main window but place them on a widget that is defined as the central widget. I am not using a layout in this particular but in general is it best practice to create a main window with no UI on it (other than menu's, etc) and to place them all on a central widget?

As per the documentation for dialogs, I have created my main window in Designer and then subclassed it to add functionality to it. Are there any differences in doing this for main windows vs. dialogs?

Thanks.

jpn
11th October 2006, 07:20
I have created a test main window in Designer and place a bunch of UI elements in it. In struggling to get it working I find that the documentation states that you should not place a layout on the main window but place them on a widget that is defined as the central widget. I am not using a layout in this particular but in general is it best practice to create a main window with no UI on it (other than menu's, etc) and to place them all on a central widget?
Designer handles this properly when you select the form's template as "Main Window". There will be created a central widget and the top level layout is set for the central widget. Take a look at some ui_*.h file generated by the UIC and you'll see.. :)



As per the documentation for dialogs, I have created my main window in Designer and then subclassed it to add functionality to it. Are there any differences in doing this for main windows vs. dialogs?
What kind of differencies do you mean? QDialog has it's own specialities like slots accept() and reject() and QMainWindow has it's own specialities like menu/status/toolbars etc. You can use a subclassed QMainWindow and/or QDialog with a designed ui installed it like any other QMainWindow and/or QDialog.