16,212
社区成员
发帖
与我相关
我的任务
分享
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMessageBox>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMessageBox
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#include<QPushButton>
#include<QVBoxLayout>
#include<QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMessageBox(parent)
// ui(new Ui::MainWindow)
{
// ui->setupUi(this);
QPushButton* m_pBtnOk = new QPushButton( tr( "是" ) );
QPushButton* m_pBtnCancel = new QPushButton( tr( "否" ) );
QHBoxLayout* pHLayout = new QHBoxLayout();
pHLayout->addWidget( m_pBtnOk );
pHLayout->addWidget( m_pBtnCancel );
QLabel*m_pLblText = new QLabel;
QLayout* pLayout = layout();
if( pLayout )
delete pLayout;
QVBoxLayout* pMainLayout = new QVBoxLayout( this );
pMainLayout->addWidget( m_pLblText,0, Qt::AlignHCenter );
pMainLayout->addLayout( pHLayout );
setLayout( pMainLayout );
}
MainWindow::~MainWindow()
{
// delete ui;
}