读书人

QPushButton的setEnabledI()如何不起作

发布时间: 2012-09-24 13:49:41 作者: rapoo

QPushButton的setEnabledI()怎么不起作用?哪里出问题了?

C/C++ code
#include "gotocell.h"#include "ui_gotocell.h"GoToCell::GoToCell(QWidget *parent) :    QWidget(parent),Ui_GoToCell(),    ui(new Ui::GoToCell){    ui->setupUi(this);    lineEdit = new QLineEdit();    butOk = new QPushButton();    QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");    lineEdit -> setValidator(new QRegExpValidator(regExp,this));}GoToCell::~GoToCell(){    delete ui;}void GoToCell::on_lineEdit_textChanged(){    butOk -> setEnabled(lineEdit -> hasAcceptableInput());    //butOk -> setEnabled(true);}




本人初学QT,这是书上的一个例子。我在设计窗体的时候把按钮butOk的Enable属性设成了false 但在程序里执行 butOk -> setEnabled(lineEdit -> hasAcceptableInput());却没有用,哪怕是直接 //butOk -> setEnabled(true);也不可以。这到底是哪里出问题了,请指教!~

[解决办法]
你这个button是你ui里面创建的?完全是两个button,你怎么改界面也不会有反应的。

读书人网 >QT开发

热点推荐