Qt4程序转向Qt5

C++ GUI Programming with Qt 4上一段代码,编译不能通过:

finddialog.cpp: In constructor 'FindDialog::FindDialog(QWidget*)':
finddialog.cpp:5:38: error: invalid use of incomplete type 'class QLabel'
In file included from finddialog.cpp:2:0:
finddialog.h:7:7: error: forward declaration of 'class QLabel'
finddialog.cpp:6:17: error: invalid use of incomplete type 'class QLineEdit'
In file included from finddialog.cpp:2:0:
finddialog.h:8:7: error: forward declaration of 'class QLineEdit'
finddialog.cpp:7:7: error: invalid use of incomplete type 'class QLabel'
In file included from finddialog.cpp:2:0:
finddialog.h:7:7: error: forward declaration of 'class QLabel'
finddialog.cpp:8:48: error: invalid use of incomplete type 'class QCheckBox'
In file included from finddialog.cpp:2:0:
finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
finddialog.cpp:9:57: error: invalid use of incomplete type 'class QCheckBox'
In file included from finddialog.cpp:2:0:
finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
finddialog.cpp:10:42: error: invalid use of incomplete type 'class QPushButton'

在Qt官网wiki找到了答案:http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5

Change all instances of

#include <QtGui>

to

#include <QtWidgets>

 

5 thoughts on “Qt4程序转向Qt5

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注