qt4项目迁移到qt5,遇到的问题及解决办法

1.解压qt5.9.6
/root/APP_QtKit_qt596_share

2.必须使用complier4.9.2
/home/dever/Works/U411/0.GCCKIT/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux

3.报错 error: QtGui/QAction: No such file or directory #include
3.1解决的方法是在.pro文件开头加上以下两行代码:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
3.2
#include
#include
去掉QtGui
#include
#include
3.3
或  自动适配
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    #include
#else
    #include
#endif

4.报错 error: QWSServer: No such file or directory
QT5没有QWS,用QPA
https://www.cnblogs.com/sankye/p/4643173.html

屏蔽代码 //#include
5.报错 error: QWSPointerCalibrationData: No such file or directory
 #include

屏蔽mywidget.cpp代码34  //#include "calibration.h"

6.报错 /root/work/GSE/AM335widget/Common/GblDataTypeDefine.h:716: error: cast from ‘UINT16* {aka short unsigned int*}’ to ‘int’ loses precision [-fpermissive]
 #define CAP_TYPE OFFSET_OF(_SYS_DSP_SET_INFO_T, u16CapType) //机型容量类型: 10,15,20,30 KVA
6.1方法一
OFFSET_OF中的int改为 long===========================不知道是否有影响=========================
6.2方法二
https://blog.csdn.net/yunwy/article/details/44732101
QMAKE_CXXFLAGS += -m32
QMAKE_LINK += -m32

7.报错 error: QInputContext: No such file or directory
QT5没有软键盘
屏蔽MainThread.cpp代码25 //#include "myinputpanelcontext.h"

8.报错 error: ‘setCodecForTr’ is not a member of ‘QTextCodec’
Qt5 取消了QTextCodec::setCodecForTr()和QTextCodec::setCodecForCString()这两个函数。直接将 QTextCodec::setCodecForLocale(QTextCodec::codecForName(“UTF8”)) 至于QApplication实例之前即可解决
 
   QTextCodec *codec = QTextCodec::codecForName("UTF-8");//"System"
 //   QTextCodec::setCodecForTr(codec);
    QTextCodec::setCodecForLocale(codec);
  //  QTextCodec::setCodecForCStrings(codec);

9.报错 'class QString' has no member named 'toAscii'.
Qt5 没有toAscii了。不过可以用toLatin1或者qPrintable()

10.报错 error: variable `QPainter painter' has initializer but incomplete type
在.cpp文件中添加  #include "qpainter.h"

11.报错 error: invalid use of incomplete type ‘class QTimerEvent’   
在.cpp文件中添加  #include

12.报错 error: ‘UnicodeUTF8’ is not a member of ‘QApplication’   
原因是:QCoreApplication::UnicodeUTF8已被弃用
修改 first_page->setText(QApplication::translate("Form2", "|<", 0, QApplication::UnicodeUTF8));
为 first_page->setText(QApplication::translate("Form2", "|<", 0));

13.报错 error This file requires compiler and library support for the ISO C++ 2011 standard.
在工程文件(pro)中加入:QMAKE_CXXFLAGS += -std=c++0x

14.报错 error: ‘ERANGE’ was not declared in this scope
=======================================================================================

https://stackoverflow.com/questions/25788614/ulong-max-was-not-declared-in-this-scope
string_conversion.h
67 else if (errno == 34//ERANGE

15.报错 error: ‘sa_family_t’ was
can.h 添加
typedef unsigned short int sa_family_t;

 

 

参考:
http://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5#846d0d314d8d4894bde364f45acf02e4

你可能感兴趣的:(嵌入式)