tags:

views:

204

answers:

3

I am currently writing a wizard-style application using Qt4. I am not using the wizard class however, since going next/back does not make sense from every step in the process.

The user starts off at a "hub"-window with five buttons, each of which take him to another window at a different stage of the process. At the beginning all but the first button of the hub are disabled. After clearing each stage, the user will be directed back to the hub and one new button/stage will get enabled.

Since every stage has significantly differing objectives, I coded every single stage as a single QWidget that gets instantiated in the main() function. To switch between the widgets, I simply hide() the one I am leaving and show() the one I am going to.
However, this leads to problems if the user resized or moved one widget, since the next widget will always show up at its default position instead of the new one.

Is there a way to synchronize the widgets' sizes and positions?

Or, better yet, is there a more elegant way to deal with those different windows than switching between several hidden widgets?

Thank you in advance!

+1  A: 

Why not just have one main QWidget as a container for your pages? That way if the user moves the main QWidget and then goes to the next page, it will still open in the new position inside the main widget.

Generally, I've never had occasion to create multiple widgets inside my main method. Don't quite see the point.

drby
because then I would have to cram hundreds of buttons and stuff in one widget, which would get a bit messy
BastiBechtold
+1  A: 

I'm beginning on something similar - with different views (perspectives) for different tasks along the way. Using toolbar icons and file menu, not buttons, to move between views. Similar to how MS Outlook allows you to have the window display email, or a calendar, or contacts, etc.

My intent (haven't started yet) is to have one QMainWindow as the application window, containing my various QWidgets that offer the various views. Depending on what task the user is doing, one composite widget will be visible, and the others hidden.

+2  A: 

Create one top-level widget that holds the others.

I suggest that you either use QStackedWidget, or, if you want more control, create your own widget and use QStackedLayout directly.

gnud