#include #include #include #include class Dialog : public QDialog { Q_OBJECT public: Dialog() { QPushButton* btn = new QPushButton("Push Me", this); connect(btn, SIGNAL(clicked()), this, SLOT(showMessages())); } private slots: void showMessages() { for (int i = 0; i < 10; ++i) { QMessageBox::information(this, "Chase the Message Dialog", "This message will show up in a different spot each time it pops up"); } } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Dialog dialog; dialog.show(); return app.exec(); } #include "main.moc"