PDA

View Full Version : MainWindow+Dialogs



fruzzo
19th May 2008, 10:41
Hi, I've a QMainWindow with inside its layout a menu of pusbuttons and a groupbox. The behaviou of my gui is this one:
- when a click on a push button of the menu I want open something like a dialog inside the area of a groupbox without create a new window for the dialog.
Is possible to do this?
For the moment instead of creating a real qdialog, a create a custom qwidget and it work:
myWidget * pMyWidget = newMyWidget();
myGroupBoxLayout->addWidget(pMyWidget );
However I have a problem of management (I think it's too hard) with this idea in the case of cascade calling of this sort of "dialogs":
MainWidow open MyWidget1, clicking on a button of this one it open MyWidget2 (always inside the area of the groupbox), clicking on a button of this one it open MyWidget3 always inside the area of the groupbox). Closing MyWidget3 must reappear MyWidget2, and closing MyWidget2 must reappear MyWidget1.
Any idea to solve this task?

aamer4yu
19th May 2008, 10:46
Have a look at QStackedWidget.

Also have a look at the Configuration Dialog example in QtDemo.

fruzzo
20th May 2008, 08:43
Have a look at QStackedWidget.

Also have a look at the Configuration Dialog example in QtDemo.

Ok that's what I want...I try to use it and works fine. I 've only 2 problems...when I put a widget on the top, and I try to modify the properties of a qlabel of it, for example, the application crash! I don' know if this behaviour is releted to the wrong management of the qwidgetstack or no.
The other problem, may be related to the first, is using the method raiseWidget ( QWidget * w ).
I create:
MyWidget * myWid = new MyWidget (widgetStack)
widgetStack->addWidget(myWid, id)
but when I call
widgetStack-> raiseWidget (myWid)
to put the widget on top the application crash.
The only way is to use:
widgetStack-> raiseWidget (id)
Why?

jpn
20th May 2008, 08:52
I 've only a problem...when I put a widget on the top, and I try to modify the properties of a qlabel of it, for example, the application crash!
I don' know if this behaviour is releted to the wrong management of the qwidgetstack or no.
It could be anything. Provided this information, there's not much we can say about it. Please, provide at least the backtrace from a debugger.