c ++类前向声明​​和无效类型的无效使用

时间:2013-02-24 00:31:25

标签: c++ qt

当我在QtCreator上运行代码时,我得到了:

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'

我的代码的一部分: dialog.h

#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

#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);
}

我不知道该怎么做。我搜索解决方案,但我找不到任何与我的问题相似的东西。谢谢你的帮助......

3 个答案:

答案 0 :(得分:5)

使用include

中的<QtGui>替换dialog.h中的<QtWidgets>

答案 1 :(得分:1)

您正在传递函数指针而不是调用函数。变化

findButton->setEnable(!text.isEmpty);

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

请注意括号。

答案 2 :(得分:0)

替换

last_tweet_id

通过

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

据我所知,这是由于版本差异造成的。 参考:https://stackoverflow.com/a/26937651/4287503