PDA

View Full Version : new window



eric
4th December 2007, 16:13
Hi all!

I would like to be able to open a new window by clicking a pushbutton. The new window would have more buttons and data aquisition widgets that can be used to enter various types of data for the program. I want some of the program to run in this new popup window. When I click an exit button, the new window should close and progam should continue running on its own course until the popup window is called again via a pushbutton.
What would be the easiest way to do that? I'd appreciate it much if someone could get me started.
Thank you.

marcel
4th December 2007, 16:17
You can connect the button's clicked() signal to a slot in your main window. There you will instantiate and show the popup dialog. Maybe it is better to make it modal(show it with exec).

eric
4th December 2007, 16:48
That's a good idea. How do you initiate a new popup window?

marcel
4th December 2007, 18:42
Well, you first have to implement your new window(either by creating it in designer, or by creating the widgets and layouts manually).
Next you have to instantiate it and display it.


void MyClass::clicked_slot()
{
MyPopup popup(this);
popup.exec();
}
Now exec() will not return until you close the popup. Note that in this case you can create the popup on the stack. If you were to use show() instead of exec then you must create it on the heap, otherwise it would get destroyed when the slot scope ends.