关于Qt4与Qt5不兼容报错

时间:2023-02-01 14:20:58

环境:mysql5.0  qt5.2.1   win7旗舰版


一、出现问题:error: QtGui/QApplication: No such file or directory       #include <QtGui/QApplication>     解决如下:
                              

1,main.cpp中

#include <QtGui/QApplication>中删除QtGui\ 改为:  

#include <QApplication>

2,在.pro文件中加

QT +=sql

greaterThan(QT_MAJOR_VERSION,4):QT+=widgets

 

二、出现问题:QCoreApplication::UnicodeUTF8 is deprecated   解决如下:

This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8. For example:

Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("Href_Gui", "Text:", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0, QApplication::UnicodeUTF8));

to

Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0));
label->setText(QApplication::translate("Href_Gui", "Text:", 0));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0));

三、更多请参考网站:Transition from Qt 4.x to Qt5 - Qt Wiki
http://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5#3a05fcdc7ec52801754a96d4b80c301b


(error-No such file or directory -CSDN问答  http://ask.csdn.net/questions/171725)