Qt错误:无效使用不完全类型'class QLabel' [英] Qt error: invalid use of incomplete type 'class QLabel'
问题描述
我试图使用QtCreater编译以下程序,但我得到了很多错误在这个程序。我从一本书得到了这个程序,我不能弄清楚错误在哪里。有人可以帮助调试此程序。
这里是FindDialog.h
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include< QDialog>
class QCheckbox;
class QLabel;
类QLineEdit;
class QPushButton;
class FindDialog:public QDialog
{
Q_OBJECT
public:
FindDialog(QWidget * parent = 0);
信号:
void findNext(const QString& str,Qt :: CaseSensitivity cs);
void findPrevious(const QString& str,Qt :: CaseSensitivity cs);
私有插槽:
void findClicked();
void enableFindButton(const QString& text);
private:
QLabel * label;
QLineEdit * lineEdit;
QCheckbox * caseCheckBox;
QCheckbox * backwardCheckBox;
QPushButton * findButton
QPushButton * closeButton;
};
#endif
FindDialog.cpp
#include< QtGui>
#includefinddialog.h
FindDialog :: FindDialog(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& backward));
findButton = new QPushButton(tr(& Find));
findButton-> 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());
}
void FindDialog :: findClicked()
{
QString text = lineEdit-> text();
Qt :: CaseSensitivity cs = caseCheckBox-> isChecked()? Qt :: CaseSensitivity
:Qt :: CaseInsensitive;
if(backwardCheckBox-> isChecked()){
emit findPrevious(text,cs);
} else {
emit findNext(text,cs);
}
}
void FindDialog :: enableFindButton(const QString& text)
{
findButton-> setEnabled(!text.isEmpty ));
}
main.cpp
#include& lt; QApplication>
#includefindDialog.h
int main(int argc,char * argv [])
{
QApplication app(argc,argv );
FindDialog * dialog = new FindDialog;
dialog-> show();
return app.exec()
}
我得到的错误如下:
finddialog.cpp:21:32:注意:候选项是:
在包含在/usr/include/qt5/QtCore/qabstractanimation.h中的文件中: 45:0,
来自/ usr / include / qt5 / QtCore / QtCore:4,
来自/ usr / include / qt5 / QtGui / QtGui:4,
来自finddialog.cpp:1 :
/usr/include/qt5/QtCore/qobject.h:199:36:note:static QMetaObject :: Connection QObject :: connect(const QObject *,const char *,const QObject *,const char * Qt :: ConnectionType)
static QMetaObject :: Connection connect(const QObject * sender,const char * signal,
^
/usr/include/qt5/QtCore/qobject.h:199: 36:注意:参数1没有已知的转换,从'QPushButton *'到'const QObject *'
/usr/include/qt5/QtCore/qobject.h:202:36:note:static QMetaObject :: Connection QObject :: connect(const QObject *,const QMetaMethod& const QObject *,const QMetaMethod& Qt :: ConnectionType)
static QMetaObject :: Connection connect(const QObject * sender,const QMetaMethod& signal,
^
/usr/include/qt5/QtCore/qobject.h:202:36:注意:没有已知的从'QPushButton *'到'const QObject *'的参数1的转换
/ usr / include /qt5/QtCore/qobject.h:418:32:note:QMetaObject :: Connection QObject :: connect(const QObject *,const char *,const char *,Qt :: ConnectionType)const
inline QMetaObject ::连接QObject :: connect(const QObject * asender,const char * asignal,
^
/usr/include/qt5/QtCore/qobject.h:418:32:注意:参数1没有已知的转换从'QPushButton *'到'const QObject *'
/usr/include/qt5/QtCore/qobject.h:215:43:note:template< class Func1,class Func2> static QMetaObject :: Connection QObject :: connect(const typename QtPrivate :: FunctionPointer< Func> :: Object *,Func1,const typename QtPrivate :: FunctionPointer Func2> :: Object *,Func2,Qt :: ConnectionType)
static inline QMetaObject :: Connection connect(const typename QtPrivate :: FunctionPointer Func1> :: Object * sender,Func1 signal,
^
/usr/include/qt5/QtCore/qobject.h:215 :43:note:模板参数推导/替换失败:
/usr/include/qt5/QtCore/qobject.h:替换'template< class Func1,class Func2> static QMetaObject :: Connection QObject :: connect (const typename QtPrivate :: FunctionPointer< Func> :: Object *,Func1,const typename QtPrivate :: FunctionPointer Func2> :: Object *,Func2,Qt :: ConnectionType)[Func1 = const char *; Func2 = const char *]':
finddialog.cpp:21:32:从这里需要
/usr/include/qt5/QtCore/qobject.h:215:43:错误:没有名为'Object' struct QtPrivate :: FunctionPointer< const char *>'
/usr/include/qt5/QtCore/qobject.h:245:13:note:template< class Func1,class Func2>静态类型名QtPrivate :: QEnableIf<((int)(QtPrivate :: FunctionPointer< Func2> :: ArgumentCount)> = 0),QMetaObject :: Connection> :: Type QObject :: connect(const typename QtPrivate :: FunctionPointer& ; :: Object *,Func1,Func2)
connect(const typename QtPrivate :: FunctionPointer< Func1> :: Object * sender,Func1 signal,Func2 slot)
^
/ usr / include /qt5/QtCore/qobject.h:245:13:note:模板参数扣除/替换失败:
finddialog.cpp:21:32:note:candidate期望有3个参数,4提供
this, (findClicked()));
^
在/usr/include/qt5/QtCore/qabstractanimation.h:45:0中包含的文件中,
来自/ usr / include / qt5 / QtCore / QtCore:4,
从/ usr / include / qt5 / QtGui / QtGui:4,
从finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:268:13:注意: template< class Func1,class Func2>静态类型名QtPrivate :: QEnableIf<(QtPrivate :: FunctionPointer< Func2> :: ArgumentCount ==(-1)),QMetaObject :: Connection> :: Type QObject :: connect(const typename QtPrivate :: FunctionPointer Func&对象*,Func1,Func2)
connect(const typename QtPrivate :: FunctionPointer< Func1> :: Object * sender,Func1 signal,Func2 slot)
^
/ usr / include / qt5 / QtCore / qobject.h:268:13:note注意:模板参数扣除/替换失败:
finddialog.cpp:21:32:note:candidate期望有3个参数,4提供
this,SLOT(findClicked )));
^
finddialog.cpp:23:61:error:没有匹配的函数调用FindDialog :: connect(QPushButton *& const char [11],FindDialog * const,const char [9] ])'
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
^
finddialog.cpp:23:61:note:候选项是:
在包含在/usr/include/qt5/QtCore/qabstractanimation.h:45:0的文件中,
从/ usr / include / qt5 / QtCore / QtCore:4,
从/ usr / include / qt5 / QtGui / QtGui:4,
从finddialog.cpp:1:
/ usr /include/qt5/QtCore/qobject.h:199:36:note:static QMetaObject :: Connection QObject :: connect(const QObject *,const char *,const QObject *,const char *,Qt :: ConnectionType)
static QMetaObject :: Connection connect(const QObject * sender,const char * signal,
^
/usr/include/qt5/QtCore/qobject.h:199:36:note:没有已知的转换参数1从'QPushButton *'到'const QObject *'
/usr/include/qt5/QtCore/qobject.h:202:36:note:static QMetaObject :: Connection QObject :: connect(const QObject * ,const QMetaMethod& const QObject *,const QMetaMethod& Qt :: ConnectionType)
static QMetaObject :: Connection connect(const QObject * sender,const QMetaMethod& signal,
^
/ usr / include / qt5 / QtCore / qobject.h:202:36:注意:没有已知的从'QPushButton *'到'const QObject *'
/ usr / include / qt5 / QtCore / qobject的转换。 h:418:32:note:QMetaObject :: Connection QObject :: connect(const QObject *,const char *,const char *,Qt :: ConnectionType)const
inline QMetaObject :: Connection QObject :: connect QObject * asender,const char * asignal,
^
/usr/include/qt5/QtCore/qobject.h:418:32:注意:没有已知的参数1从'QPushButton *'转换为' const QObject *'
/usr/include/qt5/QtCore/qobject.h:215:43:note:template< class Func1,class Func2> static QMetaObject :: Connection QObject :: connect(const typename QtPrivate :: FunctionPointer< Func> :: Object *,Func1,const typename QtPrivate :: FunctionPointer Func2> :: Object *,Func2,Qt :: ConnectionType)
static inline QMetaObject :: Connection connect(const typename QtPrivate :: FunctionPointer Func1> :: Object * sender,Func1 signal,
^
/usr/include/qt5/QtCore/qobject.h:215 :43:note:模板参数推导/替换失败:
/usr/include/qt5/QtCore/qobject.h:替换'template< class Func1,class Func2> static QMetaObject :: Connection QObject :: connect (const typename QtPrivate :: FunctionPointer< Func> :: Object *,Func1,const typename QtPrivate :: FunctionPointer Func2> :: Object *,Func2,Qt :: ConnectionType)[Func1 = const char *; Func2 = const char *]':
finddialog.cpp:23:61:从这里需要
/usr/include/qt5/QtCore/qobject.h:215:43:错误:没有名为'Object' struct QtPrivate :: FunctionPointer< const char *>'
/usr/include/qt5/QtCore/qobject.h:245:13:note:template< class Func1,class Func2>静态类型名QtPrivate :: QEnableIf<((int)(QtPrivate :: FunctionPointer< Func2> :: ArgumentCount)> = 0),QMetaObject :: Connection> :: Type QObject :: connect(const typename QtPrivate :: FunctionPointer& ; :: Object *,Func1,Func2)
connect(const typename QtPrivate :: FunctionPointer Func1> :: Object * sender,Func1 signal,Func2 slot)
^
/ usr / include /qt5/QtCore/qobject.h:245:13:注意:模板参数扣除/替换失败:
finddialog.cpp:23:61:note:candidate期望有3个参数,4提供
connect(closeButton ,SIGNAL(clicked()),this,SLOT(close()));
^
在/usr/include/qt5/QtCore/qabstractanimation.h:45:0中包含的文件中,
来自/ usr / include / qt5 / QtCore / QtCore:4,
从/ usr / include / qt5 / QtGui / QtGui:4,
从finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:268:13:注意: template< class Func1,class Func2>静态类型名QtPrivate :: QEnableIf<(QtPrivate :: FunctionPointer< Func2> :: ArgumentCount ==(-1)),QMetaObject :: Connection> :: Type QObject :: connect(const typename QtPrivate :: FunctionPointer Func&对象*,Func1,Func2)
connect(const typename QtPrivate :: FunctionPointer< Func1> :: Object * sender,Func1 signal,Func2 slot)
^
/ usr / include / qt5 / QtCore / qobject.h:268:13:注意:模板参数扣除/替换失败:
finddialog.cpp:23:61:note:candidate期望3个参数,4提供
connect(closeButton,SIGNAL clicked()),this,SLOT(close()));
^
finddialog.cpp:25:2:error:'QHBoxLayout'没有在这个范围内声明
QHBoxLayout * topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:15:error:'topLeftLayout'没有在这个范围内声明
QHBoxLayout * topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:35:error:'QHBoxLayout'之前的类型说明符
QHBoxLayout * topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:35:error:expected';'before'QHBoxLayout'
finddialog.cpp:29:2:error:'QVBoxLayout'
QVBoxLayout * leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:15:error:'leftLayout'没有在这个范围内声明
QVBoxLayout * leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:32:error:'QVBoxLayout'之前的类型说明符
QVBoxLayout * leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:32:error:expected';'before'QVBoxLayout'
finddialog.cpp:34:15:error:'rightLayout'
QVBoxLayout * rightLayout = new QVBoxLayout;
^
finddialog.cpp:34:33:error:'QVBoxLayout'之前的类型说明符
QVBoxLayout * rightLayout = new QVBoxLayout;
^
finddialog.cpp:34:33:error:expected';'before'QVBoxLayout'
finddialog.cpp:39:15:error:'mainLayout'
QHBoxLayout * mainLayout = new QHBoxLayout;
^
finddialog.cpp:39:32:error:expect'QHBoxLayout'之前的类型说明
QHBoxLayout * mainLayout = new QHBoxLayout;
^
finddialog.cpp:39:32:error:expected';'before'QHBoxLayout'
finddialog.cpp:在成员函数'void FindDialog :: findClicked()':
finddialog.cpp:50:25:error:invalid use of incomplete type'class QLineEdit'
QString text = lineEdit-> text();
^
在finddialog.cpp中包含的文件中:3:0:
finddialog.h:8:7:error:'QLineEdit'类的向前声明
class QLineEdit;
^
finddialog.cpp:51:39:error:无效使用不完整的类'QCheckbox'
Qt :: CaseSensitivity cs = caseCheckBox-> isChecked Qt :: CaseSensitivity
^
在finddialog.cpp:3:0包含的文件中:
finddialog.h:6:7:error:'QCheckbox'类的向前声明
类QCheckbox;
^
finddialog.cpp:52:17:error:期望的主表达式':'token
:Qt :: CaseInsensitive;
^
finddialog.cpp:53:21:error:无效使用不完整的类'QCheckbox'
if(backwardCheckBox-> isChecked()){
^
在从finddialog.cpp:3:0包含的文件中:
finddialog.h:6:7:error:'QCheckbox'的向前声明
class QCheckbox;
^
finddialog.cpp:在成员函数'void FindDialog :: enableFindButton(const QString&)':
finddialog.cpp:62:12:error:invalid use of incomplete type' QPushButton'
findButton-> setEnabled(!text.isEmpty());
^
在/ usr / include / qt5 / QtWidgets / QDialog:1:0,
从finddialog.h:4,
从finddialog.cpp:
/usr/include/qt5/QtWidgets/qdialog.h:52:7:error:向前声明'class QPushButton'
class QPushButton;
^
make:*** [finddialog.o]错误1
我在读同一本书。有2个事情需要修复,以使此示例工作。
-
findDialog.h头文件中的'类'转发声明不起作用,因此QLabel等的构造函数发现。使用相应的#include替换每个类,如下所示。 (在finddialog.h文件中不需要QHBoxLayout和QVBoxLayout,但为了方便起见,我移动了这些,所有必需的包含在同一个地方。)
#include< QDialog>
#include< QCheckbox> // class QCheckBox;
#include< QLabel> // class QLabel;
#include< QLineEdit> // class QLineEdit;
#include< QPushButton> // class QPushButton;
#include< QHBoxLayout> // in the finddialog.cpp
#include< QVBoxLayout> // in the finddialog.cpp
-
将.pro文件修改为:
greaterThan(QT_MAJOR_VERSION,4):QT + = widgets
TARGET = find
$ b b TEMPLATE = app
HEADERS = finddialog.h
SOURCES = finddialog.cpp \
main.cpp
The 'class' forward declarations in the findDialog.h header file do not work, so no constructor for QLabel etc can be found. Replace each class with the corresponding #include as follows. (The QHBoxLayout and QVBoxLayout are not needed in the finddialog.h file but for convenience I moved those too so that all required includes are in the same place.)
#include < QDialog> #include < QCheckBox> //class QCheckBox; #include < QLabel> //class QLabel; #include < QLineEdit> //class QLineEdit; #include < QPushButton> //class QPushButton; #include < QHBoxLayout> //in the finddialog.cpp #include < QVBoxLayout> //in the finddialog.cpp
Edit the .pro file to this:
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = find TEMPLATE = app HEADERS = finddialog.h SOURCES = finddialog.cpp \ main.cpp
Delete all the old makefiles and find.pro.user and rebuild the project.
/ ol>
I'm trying to compile the following program using QtCreater but I get a lots of errors in this program. I got this program from a book and I'm not able to figure out where the error is. Can someone help debug this program.
Here is the FindDialog.h
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <QDialog>
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
FindDialog.cpp
#include <QtGui>
#include "finddialog.h"
FindDialog::FindDialog(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 &backward"));
findButton = new QPushButton(tr("&Find"));
findButton->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());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitivity
: Qt::CaseInsensitive;
if(backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}
main.cpp
#include <QApplication>
#include "findDialog.h"
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
FindDialog *dialog = new FindDialog;
dialog->show();
return app.exec();
}
The errors I get are the following:
finddialog.cpp:21:32: note: candidates are:
In file included from /usr/include/qt5/QtCore/qabstractanimation.h:45:0,
from /usr/include/qt5/QtCore/QtCore:4,
from /usr/include/qt5/QtGui/QtGui:4,
from finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:199:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
^
/usr/include/qt5/QtCore/qobject.h:199:36: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:202:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
^
/usr/include/qt5/QtCore/qobject.h:202:36: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:418:32: note: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
^
/usr/include/qt5/QtCore/qobject.h:418:32: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:215:43: note: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType)
static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
^
/usr/include/qt5/QtCore/qobject.h:215:43: note: template argument deduction/substitution failed:
/usr/include/qt5/QtCore/qobject.h: In substitution of ‘template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = const char*; Func2 = const char*]’:
finddialog.cpp:21:32: required from here
/usr/include/qt5/QtCore/qobject.h:215:43: error: no type named ‘Object’ in ‘struct QtPrivate::FunctionPointer<const char*>’
/usr/include/qt5/QtCore/qobject.h:245: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<Func>::Object*, Func1, Func2)
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
^
/usr/include/qt5/QtCore/qobject.h:245:13: note: template argument deduction/substitution failed:
finddialog.cpp:21:32: note: candidate expects 3 arguments, 4 provided
this, SLOT(findClicked()));
^
In file included from /usr/include/qt5/QtCore/qabstractanimation.h:45:0,
from /usr/include/qt5/QtCore/QtCore:4,
from /usr/include/qt5/QtGui/QtGui:4,
from finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:268: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<Func>::Object*, Func1, Func2)
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
^
/usr/include/qt5/QtCore/qobject.h:268:13: note: template argument deduction/substitution failed:
finddialog.cpp:21:32: note: candidate expects 3 arguments, 4 provided
this, SLOT(findClicked()));
^
finddialog.cpp:23:61: error: no matching function for call to ‘FindDialog::connect(QPushButton*&, const char [11], FindDialog* const, const char [9])’
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
^
finddialog.cpp:23:61: note: candidates are:
In file included from /usr/include/qt5/QtCore/qabstractanimation.h:45:0,
from /usr/include/qt5/QtCore/QtCore:4,
from /usr/include/qt5/QtGui/QtGui:4,
from finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:199:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
^
/usr/include/qt5/QtCore/qobject.h:199:36: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:202:36: note: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
^
/usr/include/qt5/QtCore/qobject.h:202:36: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:418:32: note: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
^
/usr/include/qt5/QtCore/qobject.h:418:32: note: no known conversion for argument 1 from ‘QPushButton*’ to ‘const QObject*’
/usr/include/qt5/QtCore/qobject.h:215:43: note: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType)
static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
^
/usr/include/qt5/QtCore/qobject.h:215:43: note: template argument deduction/substitution failed:
/usr/include/qt5/QtCore/qobject.h: In substitution of ‘template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = const char*; Func2 = const char*]’:
finddialog.cpp:23:61: required from here
/usr/include/qt5/QtCore/qobject.h:215:43: error: no type named ‘Object’ in ‘struct QtPrivate::FunctionPointer<const char*>’
/usr/include/qt5/QtCore/qobject.h:245: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<Func>::Object*, Func1, Func2)
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
^
/usr/include/qt5/QtCore/qobject.h:245:13: note: template argument deduction/substitution failed:
finddialog.cpp:23:61: note: candidate expects 3 arguments, 4 provided
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
^
In file included from /usr/include/qt5/QtCore/qabstractanimation.h:45:0,
from /usr/include/qt5/QtCore/QtCore:4,
from /usr/include/qt5/QtGui/QtGui:4,
from finddialog.cpp:1:
/usr/include/qt5/QtCore/qobject.h:268: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<Func>::Object*, Func1, Func2)
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
^
/usr/include/qt5/QtCore/qobject.h:268:13: note: template argument deduction/substitution failed:
finddialog.cpp:23:61: note: candidate expects 3 arguments, 4 provided
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
^
finddialog.cpp:25:2: error: ‘QHBoxLayout’ was not declared in this scope
QHBoxLayout *topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:15: error: ‘topLeftLayout’ was not declared in this scope
QHBoxLayout *topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:35: error: expected type-specifier before ‘QHBoxLayout’
QHBoxLayout *topLeftLayout = new QHBoxLayout;
^
finddialog.cpp:25:35: error: expected ‘;’ before ‘QHBoxLayout’
finddialog.cpp:29:2: error: ‘QVBoxLayout’ was not declared in this scope
QVBoxLayout *leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:15: error: ‘leftLayout’ was not declared in this scope
QVBoxLayout *leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:32: error: expected type-specifier before ‘QVBoxLayout’
QVBoxLayout *leftLayout = new QVBoxLayout;
^
finddialog.cpp:29:32: error: expected ‘;’ before ‘QVBoxLayout’
finddialog.cpp:34:15: error: ‘rightLayout’ was not declared in this scope
QVBoxLayout *rightLayout = new QVBoxLayout;
^
finddialog.cpp:34:33: error: expected type-specifier before ‘QVBoxLayout’
QVBoxLayout *rightLayout = new QVBoxLayout;
^
finddialog.cpp:34:33: error: expected ‘;’ before ‘QVBoxLayout’
finddialog.cpp:39:15: error: ‘mainLayout’ was not declared in this scope
QHBoxLayout *mainLayout = new QHBoxLayout;
^
finddialog.cpp:39:32: error: expected type-specifier before ‘QHBoxLayout’
QHBoxLayout *mainLayout = new QHBoxLayout;
^
finddialog.cpp:39:32: error: expected ‘;’ before ‘QHBoxLayout’
finddialog.cpp: In member function ‘void FindDialog::findClicked()’:
finddialog.cpp:50:25: error: invalid use of incomplete type ‘class QLineEdit’
QString text = lineEdit->text();
^
In file included from finddialog.cpp:3:0:
finddialog.h:8:7: error: forward declaration of ‘class QLineEdit’
class QLineEdit;
^
finddialog.cpp:51:39: error: invalid use of incomplete type ‘class QCheckbox’
Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitivity
^
In file included from finddialog.cpp:3:0:
finddialog.h:6:7: error: forward declaration of ‘class QCheckbox’
class QCheckbox;
^
finddialog.cpp:52:17: error: expected primary-expression before ‘:’ token
: Qt::CaseInsensitive;
^
finddialog.cpp:53:21: error: invalid use of incomplete type ‘class QCheckbox’
if(backwardCheckBox->isChecked()) {
^
In file included from finddialog.cpp:3:0:
finddialog.h:6:7: error: forward declaration of ‘class QCheckbox’
class QCheckbox;
^
finddialog.cpp: In member function ‘void FindDialog::enableFindButton(const QString&)’:
finddialog.cpp:62:12: error: invalid use of incomplete type ‘class QPushButton’
findButton->setEnabled(!text.isEmpty());
^
In file included from /usr/include/qt5/QtWidgets/QDialog:1:0,
from finddialog.h:4,
from finddialog.cpp:3:
/usr/include/qt5/QtWidgets/qdialog.h:52:7: error: forward declaration of ‘class QPushButton’
class QPushButton;
^
make: *** [finddialog.o] Error 1
I'm reading the same book. There are 2 things that need to fixed to get this sample to work.
这篇关于Qt错误:无效使用不完全类型'class QLabel'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!