项目qt4迁移代码到qt5
Posted feiyufu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了项目qt4迁移代码到qt5相关的知识,希望对你有一定的参考价值。
并需要在pro文件里加上
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
并将引用的#include <QtGui>替换为#include <QtWidgets>
C++ GUI Programming with Qt 4上一段代码,编译不能通过:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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
1
|
#include <QtGui>
|
to
1
|
#include <QtWidgets>
|
以上是关于项目qt4迁移代码到qt5的主要内容,如果未能解决你的问题,请参考以下文章
迁移 Qt4 至 Qt5 的几个主要环节(数据库插件别拷错了地方)