小弟用VS2010开发QT 4,在学到第二章的rapid dialog design时,发现书中的源代码过不了编译。
书中的代码,是在QT Designer中加入了buttonBox,然后对buttonBox进行编译和使用信号槽机制。
VS2010的编译器编译结果为,buttonBox“使用了未定义类型QPushButton”。我查过了,所有的类名应该都是正确的,但是不知道为何过不了编译器?
同时,在connect中,buttonBox没有报错。
源代码如下:
GoToCellDialog::GoToCellDialog( QWidget *parent )
: QDialog( parent )
{
setupUi( this );
buttonBox ->button( QDialogButtonBox::Ok ) ->setEnabled( false );
QRegExp regExp( "[A-Za-z][1-9][0-9]{0,2}" );
lineEdit ->setValidator( new QRegExpValidator( regExp, this ) );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
}
void GoToCellDialog::on_lineEdit_textChanged()
{
buttonBox ->
button( QDialogButtonBox::Ok ) ->setEnabled( lineEdit - >hasAcceptableInput() );
}
请问各位大神这是为何呢?
感激不尽啊!!
------解决方案--------------------
IDE设置对不对??除了这个工程,其他的都能正常编译吗?
------解决方案--------------------
把你的pro文件内容贴出来看看吧
------解决方案--------------------
加个ui->
------解决方案--------------------
button= new QPushButton(this)
------解决方案--------------------
使用了未定义类型QPushButton 的问题 一般都是未包含头文件吧