2013-02-24 111 views
0

的当我运行QtCreator的代码我: dialog.hC++类向前声明和无效使用不完全类型

#ifndef FINDDIALOG_H 
#define FINDDIALOG_H 

#include <QDialog> 
#include <QtGui> 
#include <QWidget> 

class QCheckBox; 
class QLabel; 
class QLineEdit; 
class QPushButton; 

class FindDialog : public QDialog 
{ 
    Q_OBJECT 
public: 
    FindDialog(QWidget *parent = 0); 
signals: 
    void findNext(const QString &str,Qt::CaseSensitivity cs); 
    void findPrevious(const QString &str,Qt::CaseSensitivity cs); 
private slots: 
    void findClicked(); 
    void enableFindButton(const QString &text); 
private: 
    QLabel *label; 
    QLineEdit *lineEdit; 
    QCheckBox *caseCheckBox; 
    QCheckBox *backwardCheckBox; 
    QPushButton *findButton; 
    QPushButton *closeButton; 
}; 

#endif 

dialog.cpp:

08:23:56: Running steps for project dialog... 
08:23:56: Configuration unchanged, skipping qmake step. 
08:23:56: Starting: "/usr/bin/make" -w 
make: Entering directory `/home/entel/program/c++/dialog-build-Desktop_Qt_5_0_1_GCC_32bit-Debug' 
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/Qt5.0.1/5.0.1/gcc/mkspecs/linux-g++ -I../dialog -I/opt/Qt5.0.1/5.0.1/gcc/include -I/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets -I/opt/Qt5.0.1/5.0.1/gcc/include/QtGui -I/opt/Qt5.0.1/5.0.1/gcc/include/QtCore -I. -I. -I. -o dialog.o ../dialog/dialog.cpp 
../dialog/dialog.cpp: In constructor 'FindDialog::FindDialog(QWidget*)': 
../dialog/dialog.cpp:5:40: error: invalid use of incomplete type 'class QLabel' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:9:7: error: forward declaration of 'class QLabel' 
../dialog/dialog.cpp:6:20: error: invalid use of incomplete type 'class QLineEdit' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:10:7: error: forward declaration of 'class QLineEdit' 
../dialog/dialog.cpp:7:10: error: invalid use of incomplete type 'class QLabel' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:9:7: error: forward declaration of 'class QLabel' 
../dialog/dialog.cpp:9:47: error: invalid use of incomplete type 'class QCheckBox' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:8:7: error: forward declaration of 'class QCheckBox' 
../dialog/dialog.cpp:10:60: error: invalid use of incomplete type 'class QCheckBox' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:8:7: error: forward declaration of 'class QCheckBox' 
../dialog/dialog.cpp:12:45: error: invalid use of incomplete type 'class QPushButton' 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1:0, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:52:7: error: forward declaration of 'class QPushButton' 
../dialog/dialog.cpp:13:15: error: invalid use of incomplete type 'class QPushButton' 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1:0, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:52:7: error: forward declaration of 'class QPushButton' 
../dialog/dialog.cpp:14:15: error: invalid use of incomplete type 'class QPushButton' 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1:0, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:52:7: error: forward declaration of 'class QPushButton' 
../dialog/dialog.cpp:16:46: error: invalid use of incomplete type 'class QPushButton' 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1:0, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:52:7: error: forward declaration of 'class QPushButton' 
../dialog/dialog.cpp:17:103: error: no matching function for call to 'FindDialog::connect(QLineEdit*&, const char*, FindDialog* const, const char*)' 
../dialog/dialog.cpp:17:103: note: candidates are: 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: no known conversion for argument 1 from 'QLineEdit*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: no known conversion for argument 1 from 'QLineEdit*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: no known conversion for argument 1 from 'QLineEdit*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template argument deduction/substitution failed: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h: In substitution of 'template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = const char*; Func2 = const char*]': 
../dialog/dialog.cpp:17:103: required from here 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: error: no type named 'Object' in 'struct QtPrivate::FunctionPointer<const char*>' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:17:103: note: candidate expects 3 arguments, 4 provided 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == (-1)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:17:103: note: candidate expects 3 arguments, 4 provided 
../dialog/dialog.cpp:18:66: error: no matching function for call to 'FindDialog::connect(QPushButton*&, const char*, FindDialog* const, const char*)' 
../dialog/dialog.cpp:18:66: note: candidates are: 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template argument deduction/substitution failed: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h: In substitution of 'template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = const char*; Func2 = const char*]': 
../dialog/dialog.cpp:18:66: required from here 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: error: no type named 'Object' in 'struct QtPrivate::FunctionPointer<const char*>' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:18:66: note: candidate expects 3 arguments, 4 provided 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == (-1)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:18:66: note: candidate expects 3 arguments, 4 provided 
../dialog/dialog.cpp:19:61: error: no matching function for call to 'FindDialog::connect(QPushButton*&, const char*, FindDialog* const, const char*)' 
../dialog/dialog.cpp:19:61: note: candidates are: 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:211:36: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:214:36: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:430:32: note: no known conversion for argument 1 from 'QPushButton*' to 'const QObject*' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: note: template argument deduction/substitution failed: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h: In substitution of 'template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = const char*; Func2 = const char*]': 
../dialog/dialog.cpp:19:61: required from here 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:227:43: error: no type named 'Object' in 'struct QtPrivate::FunctionPointer<const char*>' 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:257:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:19:61: note: candidate expects 3 arguments, 4 provided 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qwidget.h:46:0, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:45, 
       from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == (-1)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func1>::Object*, Func1, Func2) 
/opt/Qt5.0.1/5.0.1/gcc/include/QtCore/qobject.h:280:13: note: template argument deduction/substitution failed: 
../dialog/dialog.cpp:19:61: note: candidate expects 3 arguments, 4 provided 
../dialog/dialog.cpp:21:5: error: 'QHBoxLayout' was not declared in this scope 
../dialog/dialog.cpp:21:18: error: 'topLeftLayout' was not declared in this scope 
../dialog/dialog.cpp:21:38: error: expected type-specifier before 'QHBoxLayout' 
../dialog/dialog.cpp:21:38: error: expected ';' before 'QHBoxLayout' 
../dialog/dialog.cpp:25:5: error: 'QVBoxLayout' was not declared in this scope 
../dialog/dialog.cpp:25:18: error: 'leftLayout' was not declared in this scope 
../dialog/dialog.cpp:25:35: error: expected type-specifier before 'QBoxLayout' 
../dialog/dialog.cpp:25:35: error: expected ';' before 'QBoxLayout' 
../dialog/dialog.cpp:30:5: error: 'QVBoxLayoout' was not declared in this scope 
../dialog/dialog.cpp:30:19: error: 'rightLayout' was not declared in this scope 
../dialog/dialog.cpp:30:37: error: expected type-specifier before 'QVBoxLayout' 
../dialog/dialog.cpp:30:37: error: expected ';' before 'QVBoxLayout' 
../dialog/dialog.cpp:35:5: error: 'QHBoxLayoout' was not declared in this scope 
../dialog/dialog.cpp:35:19: error: 'mainLayout' was not declared in this scope 
../dialog/dialog.cpp:35:36: error: expected type-specifier before 'QHBoxLayout' 
../dialog/dialog.cpp:35:36: error: expected ';' before 'QHBoxLayout' 
../dialog/dialog.cpp: In member function 'void FindDialog::findClicked()': 
../dialog/dialog.cpp:46:28: error: invalid use of incomplete type 'class QLineEdit' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:10:7: error: forward declaration of 'class QLineEdit' 
../dialog/dialog.cpp:47:42: error: invalid use of incomplete type 'class QCheckBox' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:8:7: error: forward declaration of 'class QCheckBox' 
../dialog/dialog.cpp:49:25: error: invalid use of incomplete type 'class QCheckBox' 
In file included from ../dialog/dialog.cpp:1:0: 
../dialog/dialog.h:8:7: error: forward declaration of 'class QCheckBox' 
../dialog/dialog.cpp: In member function 'void FindDialog::enableFindButton(const QString&)': 
../dialog/dialog.cpp:56:15: error: invalid use of incomplete type 'class QPushButton' 
In file included from /opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/QDialog:1:0, 
       from ../dialog/dialog.h:4, 
       from ../dialog/dialog.cpp:1: 
/opt/Qt5.0.1/5.0.1/gcc/include/QtWidgets/qdialog.h:52:7: error: forward declaration of 'class QPushButton' 
../dialog/dialog.cpp:56:33: error: cannot convert 'QString::isEmpty' from type 'bool (QString::)()const' to type 'bool' 
../dialog/dialog.cpp:56:33: error: in argument to unary ! 
make: *** [dialog.o] Error 1 
make: Leaving directory `/home/entel/program/c++/dialog-build-Desktop_Qt_5_0_1_GCC_32bit-Debug' 
08:23:57: The process "/usr/bin/make" exited with code 2. 
Error while building/deploying project dialog (kit: Desktop Qt 5.0.1 GCC 32bit) 
When executing step 'Make' 

我的代码一些部分

#include "dialog.h" 

FindDialog::FindDialog(QWidget *parent) : QDialog(parent) 
{ 
    label = new QLabel(tr("Find &what")); 
    lineEdit = new QLineEdit; 
    label->setBuddy(lineEdit); 

    caseCheckBox = QCheckBox(tr("Match &case")); 
    backwardCheckBox = new QCheckBox(tr("Search &backward")); 

    findButton = new QPushButton(tr("&Find")); 
    findButton->setDefault(true); 
    findButton->setEnable(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 QBoxLayout; 
    leftLayout->addLayout(topLeftLayout); 
    leftLayout->addWidget(caseCheckBox); 
    leftLayout->addWidget(backwardCheckBox); 

    QVBoxLayoout *rightLayout = new QVBoxLayout; 
    rightLayout->addWidget(findButton); 
    rightLayout->addWidget(closeButton); 
    rightLayout->addStretch(); 

    QHBoxLayoout *mainLayout = new QHBoxLayout; 
    mainLayout->addLayout(leftLayout); 
    mainLayout->addLayout(rightLayout); 
    setLayout(mainLayout); 

    setWindowTitle(tr("Find")); 
    setFixedHeight(sizeHint().height()); 
} 

void FindDialog::findClicked() 
{ 
    QString text = lineEdit->text(); 
    Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive 
                 : Qt::CaseInsensitive; 
    if (backwardCheckBox->isChecked()) 
     emit findPrevious(text,cs); 
    else emit findNext(text,cs); 
} 

void FindDialog::enableFindButton(const QString &text) 
{ 
    findButton->setEnable(!text.isEmpty); 
} 

我不知道该怎么办。我寻找解决方案,但我没有发现任何类似于我的问题.T hank的任何帮助...

+0

看起来像Qt标题找不到。您是否将这些标头所在的文件夹添加到项目的其他包含目录中? – 2013-02-24 00:33:53

回答

1

您正在传递函数指针,而不是调用该函数。更改

findButton->setEnable(!text.isEmpty); 

findButton->setEnable(!text.isEmpty()); 

注意括号。

+0

哦,谢谢你......但是它也把其他错误... – Entel 2013-02-24 00:37:06

+1

好吧,如果还有其他错误,还有其他错误,但这应该照顾你问的那个,所以你仍然得到这个:错误:无法将类型'bool(QString ::)()const'中的'QString :: isEmpty'转换为类型'bool'../dialog/dialog.cpp:56:33:错误:在一元参数中! – wilsonmichaelpatrick 2013-02-24 00:44:36

5

在包括

+1

您需要标记代码才能正确显示。用户界面上有一个{}按钮 - 突出显示代码,然后单击该按钮。我在这里为你编辑它。 – Flexo 2013-05-25 11:55:12

0

取代<QtGui>在dialog.h通过<QtWidgets>更换

class QCheckBox; 
class QLabel; 
class QLineEdit; 
class QPushButton; 

通过

#include <QCheckBox> 
#include <QLabel> 
#include <QLineButton> 
#include <QPushButton> 
#include <QHBoxLayout> 
#include <QVBoxLayout> 

据对我来说,这是由于版本差异。 参考:https://stackoverflow.com/a/26937651/4287503