Reputation: 3263
I would like to open a modal dialog box (to log in) from a static function after the QMainWindow object is opened.
class DialogLog : public QDialog {
DialogLog(QWidget * parent) : QDialog(parent) {
//some code
exec();
}
};
class LogHandler {
static bool log(QWidget * parent) {
DialogLog dl(parent);
//some code
}
};
class WinMain : public QMainWindow {}
main(..) {
QApplication app(..);
WinMain fen;
fen.show;
app.exec();
};
EDIT : How can i run LogHandler::log() after/at the same time of WinMain ?
Upvotes: 1
Views: 500
Reputation: 27027
There could be a better solution, but here is what you could do : use a singleshot timer that will shot immediatly (i.e. as soon as the event pump will be looping).
The timer will call a slot of, for instance, your WinMain
class :
void main(..) {
QApplication app(..);
WinMain fen;
fen.show;
QTimer::singleShot(0, &fen, SLOT(login()));
app.exec();
};
In the login()
slot of WinMain
you would have your call to LogHandler::log()
:
void WinMain::login() {
if (!LogHandler::log(this))
qApp->quit();
}
Upvotes: 2