Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt无法识别声明的类_Qt_Compiler Errors - Fatal编程技术网

Qt无法识别声明的类

Qt无法识别声明的类,qt,compiler-errors,Qt,Compiler Errors,我使用Qt4.6.3为FriendlyARM编写应用程序。我试图将2个指针(指向类axesParam1和mainWin)传递到当前类localTime,但出现以下错误: localtime.h:17: error: 'axesParam1' has not been declared localtime.h:18: error: 'mainWin' has not been declared localtime.h:26: error: ISO C++ forbids declaration o

我使用Qt4.6.3为FriendlyARM编写应用程序。我试图将2个指针(指向类
axesParam1
mainWin
)传递到当前类
localTime
,但出现以下错误:

localtime.h:17: error: 'axesParam1' has not been declared localtime.h:18: error: 'mainWin' has not been declared localtime.h:26: error: ISO C++ forbids declaration of 'axesParam1' with no type localtime.h:26: error: expected ';' before '*' token localtime.h:27: error: ISO C++ forbids declaration of 'mainWin' with no type localtime.h:27: error: expected ';' before '*' token In file included from trackinputstatus.h:5, from trackinput.h:5, from mainwin.h:8, from geoparam.h:5, from axesparam3.h:5, from axesparam2.h:5, from axesparam1.h:5, from main.cpp:14: trackparamstatus.h:16: error: 'mainWin' has not been declared trackparamstatus.h:24: error: ISO C++ forbids declaration of 'mainWin' with no type trackparamstatus.h:24: error: expected ';' before '*' token main.cpp: In function 'int main(int, char**)': main.cpp:52: error: no matching function for call to 'localTime::setChildren(axesParam1*)' localtime.h:17: note: candidates are: void localTime::setChildren(int*) main.cpp:61: error: no matching function for call to 'localTime::setHome(mainWin*)' localtime.h:18: note: candidates are: void localTime::setHome(int*) main.cpp:62: error: no matching function for call to 'trackParamStatus::setHome(mainWin*)' trackparamstatus.h:16: note: candidates are: void trackParamStatus::setHome(int*)
你看起来太低了。在查看setChildern之前,您应该先查看AxeParam1和/或mainwin

localtime.h:17:错误:“axesParam1”尚未声明 localtime.h:18:错误:“mainWin”尚未声明


您之前有一些syntex错误。setChildern只是一些后续错误。

您是否将
localtime.h
包含在
axesparam1.h
mainwin.h
中?@thuga我正在main.cpp中使用它。我认为当cpp文件未扩展/实现时,声明的头文件(因此声明的类)被限制为单个cpp文件。或者我遗漏了什么?如果
axesparam1.h
包含
localtime.h
,则由于
#ifndef
行位于
.h
文件的开头,声明将被跳过。这就是为什么我要求您检查
axesparam1.h
是否包含
localtime.h
@thuga,那么当我需要在多个类中使用该类时该怎么办?您使用前向声明。您可以从
localtime.h
中删除
axesparam1.h
mainwin.h
包含,并向前声明这些类。然后将这些标题包括在
localtime.cpp
文件中。 #ifndef LOCALTIME_H #define LOCALTIME_H #include <QWidget> #include "axesparam1.h" #include "mainwin.h" namespace Ui { class localTime; } class localTime : public QWidget { Q_OBJECT public: localTime(QWidget *parent = 0); ~localTime(); void setChildren(axesParam1 *); void setHome(mainWin *); protected: void changeEvent(QEvent *e); private: Ui::localTime *ui; axesParam1 *P1; mainWin *w; }; #endif // LOCALTIME_H