Qt4.7 升级至 Qt5.3遇到的项目编译不过问题

1、  #include <QtGui/QApplication> ---> No such file or directory 问题的解决 (原因是Qt5源文件位置的改动)
1).pro文件中,在 QT       += core gui 下面一行添加
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
2)在mian.cpp文件中将#include <QtGui/QApplication>
修改为 #include <QApplication>

2、 error: 'UnicodeUTF8' is not a member of 'QApplication'
         Dialog->setWindowTitle(QApplication::translate("Dialog", "hexMerger", 0, QApplication::UnicodeUTF8));
                
该问题是由于UnicodeUTF8 在 Qt5.3中已被弃用,解决办法是
QApplication::UnicodeUTF8 这个参数删除,如下示:
Dialog->setWindowTitle(QApplication::translate("Dialog", "hexMerger", 0));

其它一些思路:

1、Qt4的项目filebrowser,到qt5的编译器下面,结果编译出一堆的错误。

第一个想法是新建一个QT5的工程,对比工程.pro文件,然后看包含的namespace,发现以前的 widget,QFileSystemModel,QPushButton等都不在QtGui这个namespace下面了,这些全部迁移到一个新的命名 空间QtWidgets下面了,所以和widget有关的改下头文件就OK啦。

2、有个办法可以通用,还是看帮助文档,主要看以前用的哪些namespace在新库中是在哪里,比如以前经常用的QtGui,查看帮助文档发现以下一句话:

The Qt GUI module providesclasses for windowing system integration, event handling, OpenGL and OpenGL ESintegration, 2D graphics, basic imaging, fonts and text. 

说明qt gui包含了这些模块。

原文地址:https://www.cnblogs.com/aqing1987/p/4184012.html