平台:RK3128
版本:Qt4.8.4->Qt5.14.2
一、修改工程Pro文件Qt5 相较于Qt4的一个比较大的改变是将 widget 从 QtGui 模块中脱离,改为了 QtWidgets 模块。
#.pro文件中增加: greaterThan(QT_MAJOR_VERSION, 4): QT += widgets二、修改头文件
在Qt5中直接编译Qt4程序会有一大堆头文件找不到,他们大多只是被移动了位置
//Qt4 #include
修改为:
//Qt5 #include
#include
#include
......
三、程序中部分编译错误的解决方法error: ‘class QHeaderView’ has no member named ‘setResizeMode’
将 setResizeMode 替换为为 setSectionResizeMode
error: ‘class QHeaderView’ has no member named ‘setClickable’; did you mean ‘sectionsClickable’?
替换为为setSectionsClickable
error: use of deleted function ‘QVariant::QVariant(Qt::GlobalColor)’
return QVariant(Qt::black);
修改为
QVariant color_var;
color_var = QColor(Qt::black);
return color_var;
error: ‘class QString’ has no member named ‘toAscii’ QByteArray ba = str_id.toAscii(); ^~~~~~~
替换为为toLatin1
qcustomplot.o:在函数‘QCustomPlot::savePdf(QString const&, int, int, QCP::ExportPen, QString const&, QString const&)’中:
对‘QPrinter::QPrinter(QPrinter::PrinterMode)’未定义的引用
对‘QPrinter::setOutputFileName(QString const&)’未定义的引用
pro文件中加入qtHaveModule(printsupport): QT += printsupport



