Qt程序错误

C++语言 码拜 9年前 (2016-05-07) 1924次浏览
代码如下,是抄写的《Qt学习之路》的代码,本人的环境是QT+VS
错误:没有程序变量backwardCheckBox、findButton
没有成员enableFindButton
代码:
#include <qttest1.h>
#include <QtWidgets/QDialog>
#include<QtGui>
#include “ui_qttest1.h”
#include <QGridLayout>
QTtest1::QTtest1(QWidget *parent)
: QDialog(parent)
{
label = new QLabel(tr(“Find &what:”));
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(tr(“Match &case”));
backwardCheckBox = new QCheckBox(tr(“Search &backford”));
findButton = new QPushButton(tr(“&Find”));
findButotn->setDefault(true);
findButton->setEnabled(false);
closeButton = new QPushButton(tr(“Close”));
connect(lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(enableFindButton(const QString&)));
connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(backwardCheckBox);
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch;
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr(“Find”));
setFixedHeight(sizeHint.height());
}
QTtest1::~QTtest1()
{
}
void QTtest1::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseInsensitive : Qt::CaseSensitive;
if (backwardCheckBox->isChecked())
{
emit findPrevious(text,cs);
}
else{
emit findNext(text,cs);
}
}
void QTtest1::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}
求高手指点
解决方案

60

把你的头文件贴一下

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Qt程序错误
喜欢 (0)
[1034331897@qq.com]
分享 (0)