Qt程序的自定义对话框不能显示
#include<QtGui>class MyDlg : public QDialog{public: MyDlg(const QString &);};MyDlg::MyDlg(const QString &a){ QLabel *text=new QLabel(a); QPushButton *okbutton=new QPushButton(tr("Ok")); QPushButton *cancelbutton=new QPushButton(tr("Cancel")); QHBoxLayout *buttonlayout=new QHBoxLayout; buttonlayout->addWidget(okbutton); buttonlayout->addWidget(cancelbutton); QVBoxLayout *vboxlayout=new QVBoxLayout; vboxlayout->addWidget(text); vboxlayout->addLayout(buttonlayout); setLayout(vboxlayout);}int main(int argc,char *argv[]){ QApplication app(argc,argv); bool ok; QFont font = QFontDialog::getFont(&ok, QFont("Times", 12)); if (ok) { MyDlg choose(QObject::tr("You have chosen a font")); choose.show(); } else { MyDlg choose(QObject::tr("default font")); choose.show(); } return app.exec();}