• 3003阅读
  • 1回复

QT 4.51 Creator中,无法添加代码 [复制链接]

上一主题 下一主题
离线niyinhai
 
只看楼主 倒序阅读 楼主  发表于: 2009-05-12
跟着programming with QT 4,用Creator进行到第二部分。
化好了界面,然后需要引用界面接中button,进行判断lineEdit中是否有东西,而激活。
在主头文件中加入
  private slots:
    void on_lineEdit_textChanged(QString );
在CPP文件中,加入
void GoToCellDialog::on_lineEdit_textChanged()
{
    okButton->setEnabled(lineEdit->hasAcceptableInput());
}

调试结果,为
C:/Documents and Settings/S/My Documents/Five/mainwindow.cpp:18: error: `okButton' undeclared (first use this function);
C:/Documents and Settings/S/My Documents/Five/mainwindow.cpp:18: error: `lineEdit' undeclared (first use this function);

CPP中已经加入了代码:
     #include "ui_mainwindow.h"

请高手解决问题
离线平常道
只看该作者 1楼 发表于: 2009-05-15
还是那个问题,在QtCreator中,对使用设计器创建的窗体,不是使用Programming with Qt4里的继承处理方式
而是使用的组合,添加了一个ui成员变量。
对于.ui文件中的类成员访问,应该使用ui->。。。的方式
快速回复
限100 字节
 
上一个 下一个