tags:

views:

185

answers:

2

I'm working on a project in C++ and QT, and I want to open a new QWidget window, have the user interact with it, etc, then have execution return to the method that opened the window. Example (MyClass inherits QWidiget):

void doStuff(){

     MyClass newWindow = new Myclass();
     /* 
        I don't want the code down here to 
        execute until newWindow has been closed
      */
}

I feel like there is most likely a really easy way to do this, but for some reason I can't figure it out. How can I do this?

A: 

Why not put the code you don't want to be executed till the window has closed in a separate function and connect this as a SLOT for the window's close SIGNAL?

dirkgently
Thanks, that sounds like a good idea. How would I do this? I've never hard-coded signals/slots, only used them through QTDesigner.
Jarek
You will have to modify the source code files.
dirkgently
+7  A: 

Have MyClass inherit QDialog. Then open it as a modal dialog with exec().

void MainWindow::createMyDialog()
{
  MyClass dialog(this);
  dialog.exec();
}

Check out http://doc.trolltech.com/4.5/qdialog.html

Mark Beckwith
That was exactly what I was looking for, thank you!
Jarek
Glad I could help.
Mark Beckwith