初学QT,不知道下面的程序窗口为什么显示不了pushbutton,求过路人指点
[size=18px]MessageBoxs.cpp:
#include "MessageBoxs.h"#include <QtGui>MessageBoxs::MessageBoxs(QWidget *parent):QDialog(parent){ setWindowTitle(tr("Custom test~~")); QPushButton *PushButton_Custom = new QPushButton("Custom"); PushButton_Custom->setText(tr("Custom..")); QGridLayout *GridLayout = new QGridLayout; GridLayout->addWidget(PushButton_Custom,0,1); GridLayout->setMargin(10); GridLayout->setSpacing(20); connect(PushButton_Custom,SIGNAL(clicked()),this,SLOT(Slot_Custom()));}MessageBoxs::~MessageBoxs(){}void MessageBoxs::Slot_Custom(){}
#ifndef MESSAGEBOX_H#define MESSAGEBOX_H#include <QDialog>class MessageBoxs:public QDialog{ Q_OBJECTpublic: MessageBoxs(QWidget *parent = 0); ~MessageBoxs();public slots: void Slot_Custom();};#endif
#include <qapplication.h>#include <QPushButton>#include "MessageBoxs.h"int main(int argc,char **argv){ QApplication app(argc,argv); //QPushButton PushButton_Custom("hello world!!"); //PushButton_Custom.show(); MessageBoxs *MessageBoxs_Custom = new MessageBoxs(); MessageBoxs_Custom->show(); return app.exec();}