升级到QT6.0后,编译器告诉我
qzxing/src/QZXing.cpp:16: error: 'QtCore/QTextCodec' file not found
qzxing/src/QZXing.cpp:16:10: fatal error: 'QtCore/QTextCodec' file not found
#include <QtCore/QTextCodec>
^~~~~~~~~~~~~~~~~~~
qzxing/src/QZXing.cpp:16:10: note: did not find header 'QTextCodec' in framework 'QtCore' (loaded from '/Applications/Qt/6.0.0/clang_64/lib')
根据Qt文档,可以通过添加QT += core5compat
来导入。然而,编译器告诉我“QT: core5compat中的未知模块”。
如何解决这个问题?
发布于 2020-12-21 01:30:44
QT += core5compat
文件中添加.pro。#include <QtCore/QTextCodec>
替换为#include <QTextCodec>
发布于 2020-12-20 16:14:20
QTextCodec类被移到core5compat子模块中,因此仅在.pro中添加这个内容是不够的,但是您必须将导入更正为:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtCore/QTextCodec>
#else
#include <QtCore5Compat/QTextCodec>
#endif
或者简单的
#include <QTextCodec>
另一方面,您必须安装这个模块,因为它不是默认的,为此您必须使用维护工具。
发布于 2021-06-26 02:32:21
在greaterThan(QT_MAJOR_VERSION,5): QT += core5compat
文件中添加.pro
https://stackoverflow.com/questions/65379825
复制相似问题