#include #include #include #include #include #include #include int main( int argc, char* argv[] ) { QApplication app(argc, argv); // dialog with button opening a popup QMainWindow mainFrame; QWidget centralWidget( &mainFrame ); centralWidget.setLayout( new QVBoxLayout() ); QPushButton* QDialog_button = new QPushButton( "Show QDialog popup", ¢ralWidget ); QPushButton* QMessageBox_button = new QPushButton( "Show QMessageBox popup", ¢ralWidget ); centralWidget.layout()->addWidget( QDialog_button ); centralWidget.layout()->addWidget( QMessageBox_button ); mainFrame.setCentralWidget( ¢ralWidget ); // QDialog-based popup QDialog popup( &mainFrame ); popup.setLayout( new QVBoxLayout() ); popup.layout()->addWidget( new QLabel( "Hello World using QDialog!", &popup ) ); // QMessageBox-based popup QMessageBox message( &mainFrame ); message.setText( "Hello World using QMessageBox!" ); QObject::connect( QDialog_button, SIGNAL(clicked()), &popup, SLOT(exec()) ); QObject::connect( QMessageBox_button, SIGNAL(clicked()), &message, SLOT(exec()) ); mainFrame.show(); return app.exec(); }