- 1、本文档共7页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
从Qt4.x升级至Qt5工程代码需做的改变
分类: Qt 2013-07-28 00:31197人阅读评论(0)收藏举报
目录(?)[+]
原文链接:点击打开链接
The transition from Qt 4.x to Qt 5 is not expected to be significant. However, the “modularization” of the Qt code base requires some amount of changes to project configuration, such as use of “headers”, and configuration of project build settings (such as changes to the *.pro files).
Qt Creator (master) is compiled using Qt 4 and Qt 5; you can refer to its sources to get an overview of what is required to port an application and keep the sources backwards compatible to Qt 4.
QtWidgets as a Separate Module
example compile time errors
error: QMainWindow: No such file or directory
error: QToolButton: No such file or directory
error: QWidget: No such file or directory
Solution
Add this in your *.pro file:
QT += widgets
Change all instances of
#include QtGui
to
#include QtWidgets
The code should work now, though sometimes you may require to be more explicit:
#include QtWidgets/QToolButton
QtWebKitWidgets is also a separate module:
example compile time errors
error: invalid use of incomplete type class QWebFrame
error: forward declaration of class QWebFrame
Solution
Add this in your *.pro file:
QT += webkitwidgets
Note: when you have QT += webkitwidgets you don’t need QT += widgets
In addition, replace all instances of
#include QtWebKit
to
#include QtWebKitWidgets
You can try this by porting a WYSISWYG html editor [] from Qt 4 to Qt 5.
QPrinter Doesn’t Work
If your code has the following lines:
#include QPrinter
#include QPrintDialog
add the following to your project file:
QT += printsupport
Again, sometimes it may not work and you would need to be explicit:
#include QtPrintSupport/QPrinter
#include QtPrintSupport/QPrintDialog
toAscii() and fromAscii() Methods are deprecated
Replace all instances of
fromAscii()
toAscii()
to
fromLatin1()
toLatin1()
For example, given the Qt 4 code
QByteArray configfileti = TMP_Config.toAscii();
you would change to
QByteArray configfilet
您可能关注的文档
最近下载
- 2024年银行考试-授信业务资格笔试参考题库含答案.docx
- 2023-2024学年重庆市高二上册数学期末试卷1(人教版).docx VIP
- 园林景观施工技术交底记录大全.docx
- 期末周末作业题(含解析)2024-2025学年人教新目标(Go for it)版英语八年级上册.docx VIP
- 2024山西省农商银行招聘1340人笔试模拟试题及答案解析.docx
- 人教版2024-2025学年度第一学期七年级期末数学试卷.docx
- 可信数据空间建设及应用参考指南1.0.docx
- 2024江苏高考政治真题(原卷版).docx
- 三年级数学上册专项练习(拔高题)北师大版.pdf
- Rhino5.0&KeyShot产品设计实例教程(第2版).ppt VIP
文档评论(0)