There must be some other problem because your code looks good to me. Here's how I do it:
#include <QtGui> class Dialog : public QDialog { public: Dialog() { QDialog *subDialog = new QDialog; subDialog->setWindowTitle("Sub Dialog"); QPushButton *button = new QPushButton("Push to open new dialog", this); connect(button, SIGNAL(clicked()), subDialog, SLOT(show())); } }; class MainWindow : public QMainWindow { public: MainWindow() { Dialog *dialog = new Dialog; dialog->setWindowTitle("Dialog"); dialog->show(); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.setWindowTitle("Main Window"); w.show(); return a.exec(); }
By the way, notice how I plugged in QPushButton "clicked" a signal into the "show" QDialog slot. Very comfortably.
source share