买了一本霍老师的快速入门自学。编译3-1有问题。问一下为什么。以下是编译错误报告:
..\mywidget1\main.cpp: In function 'int qMain(int, char**)':..\mywidget1\main.cpp:5:20: error: variable 'QApplication a' has initializer but incomplete type QApplication a(argc, argv); ^ ..\mywidget1\main.cpp:11:35: error: invalid use of incomplete type 'class QWidget' QWidget *widget = new QWidget(); ^ In file included from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobject.h:48:0, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qabstractanimation.h:37, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/QtCore:4, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtGui/QtGuiDepends:3, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtGui/QtGui:3, from ..\mywidget1\main.cpp:1: E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qmetatype.h:1314:7: error: forward declaration of 'class QWidget' class QWidget; ^ ..\mywidget1\main.cpp:14:11: error: invalid use of incomplete type 'class QWidget' widget->setWindowTitle(QObject::tr("鎴戞槸widget")); ^ In file included from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobject.h:48:0, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qabstractanimation.h:37, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/QtCore:4, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtGui/QtGuiDepends:3, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtGui/QtGui:3, from ..\mywidget1\main.cpp:1: E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qmetatype.h:1314:7: error: forward declaration of 'class QWidget' class QWidget; ^ ..\mywidget1\main.cpp:17:5: error: 'QLabel' was not declared in this scope QLabel *label = new QLabel(); ^ ..\mywidget1\main.cpp:17:13: error: 'label' was not declared in this scope QLabel *label = new QLabel(); ^ ..\mywidget1\main.cpp:17:25: error: expected type-specifier before 'QLabel' QLabel *label = new QLabel(); ^ ..\mywidget1\main.cpp:28:13: error: 'label2' was not declared in this scope QLabel *label2 = new QLabel(widget); ^ ..\mywidget1\main.cpp:28:26: error: expected type-specifier before 'QLabel' QLabel *label2 = new QLabel(widget); ^ ..\mywidget1\main.cpp:36:11: error: invalid use of incomplete type 'class QWidget' widget->show(); ^ In file included from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobject.h:48:0, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qabstractanimation.h:37, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/QtCore:4, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtGui/QtGuiDepends:3, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtGui/QtGui:3, from ..\mywidget1\main.cpp:1: E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qmetatype.h:1314:7: error: forward declaration of 'class QWidget' class QWidget; ^ ..\mywidget1\main.cpp:39:12: error: type '<type error>' argument given to 'delete', expected pointer delete label; ^ ..\mywidget1\main.cpp:40:12: warning: possible problem detected in invocation of delete operator: [-Wdelete-incomplete] delete widget; ^ ..\mywidget1\main.cpp:11:14: warning: 'widget' has incomplete type QWidget *widget = new QWidget(); ^ In file included from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobject.h:48:0, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qabstractanimation.h:37, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/QtCore:4, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtGui/QtGuiDepends:3, from E:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtGui/QtGui:3, from ..\mywidget1\main.cpp:1: E:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qmetatype.h:1314:7: warning: forward declaration of 'class QWidget' class QWidget; ^ ..\mywidget1\main.cpp:40:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined delete widget;
|