Qt新手求助
Calculator::Calculator(QWidget*parent) {
QVBoxLayout*H = new QVBoxLayout(this);
ZERO = new QPushButton(tr("0"), this);
ONE = new QPushButton(tr("1"), this);
TWO = new QPushButton(tr("2"), this);
H->addWidget(ZERO);
H->addWidget(ONE);
H->addWidget(TWO);
}
int main(int argc,char*argv[]){
QApplication app(argc,argv);
Calculator a;
a.show();
return app.exec();}
class Calculator : public QDialog表明了Calculator是继承QDialog的,那么你写了这么多的代码,也都是在写Calculator这个类,在main函数,也该去实例化Calculator这个类的,父类QDialog你并没做任何的初始化,因为默认:
Calculator(QWidget *parent = 0);parent指针是0.