Dialog::~Dialog()
{
delete ui;
QPushButton *button = new QPushButton(tr("this"),this);
// button->move(200,200);
//button->show();
// button->setAttribute(Qt::WA_DeleteOnClose);
button->setGeometry(QRect(QPoint(50,50),QSize(200,50)));
// connect(button,SIGNAL(released()),this,SLOT(DoWhat()));
// button->setDefault(true);
}
代码如上,为什么dialog上不显示button。
------解决方案--------------------
你写在析构函数上干什么 放构造函数上
------解决方案--------------------
Dialog::~Dialog()注意红色的部分,这个是析构函数,new控件的代码应该写到构造函数里。
{
delete ui;
QPushButton *button = new QPushButton(tr("this"),this);
// button->move(200,200);
//button->show();
// button->setAttribute(Qt::WA_DeleteOnClose);
button->setGeometry(QRect(QPoint(50,50),QSize(200,50)));
// connect(button,SIGNAL(released()),this,SLOT(DoWhat()));
// button->setDefault(true);
}