T.Poe
T.Poe

Reputation: 2079

How to show main window after hiding it from a dialog window in Qt

I'm displaying mainwindow in one function with this code:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Engine engine;
    MainWindow w(&engine);

    w.show();

    return a.exec();
}

Then in mainWindow I hide it and display dialog window with this code:

this->hide();
SomeDialog x;
x.setModal(true);
x.exec();

And then in the new SomeDialog window code I want to do something like this:

this->close();
parentMainWindow.show();

I think it would be possible by passing the parent MainWindow object to the constructors but I wonder whether there is some other option. Is there?

Upvotes: 2

Views: 2527

Answers (1)

skypjack
skypjack

Reputation: 50540

show is a slot of QMainWindow. You can bind it to the signals accepted and rejected of your dialog or whatever signal you plan to emit.

See here, here and here for further details.

Upvotes: 1

Related Questions