Qt5:错误:'WA_LockPortraitOrientation'不是'Qt'的成员
Qt5: error: 'WA_LockPortraitOrientation' is not a member of 'Qt'
我正在尝试将Qt4/Symbian项目编译为Qt5,同时保留对Qt4/Symbian的支持。
目前,MainWindow::setOrientation
自动生成的样板函数给我带来了麻烦。
它给了我这些编译器错误:
error: 'WA_LockPortraitOrientation' is not a member of 'Qt'
error: 'WA_LockLandscapeOrientation' is not a member of 'Qt'
error: 'WA_AutoOrientation' is not a member of 'Qt'
是的,正如您自己指出的那样,这些在Qt 5中删除了。
原因是这些是Symbian独有的功能,如果他们只在某个平台上工作,特别是如果Qt 5本身不支持该平台,那么这些事情只会让Qt用户感到困惑。
相应的 gerrit 更改可以在此处找到:
https://codereview.qt-project.org/#change,11280
您需要更改这些行
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
对这些:
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
// Qt 5 has removed them.
有
条件地允许基于Qt版本的某些功能的好方法是:
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
...
#endif
它比硬编码十六进制值更干净、更好。这也是现有Qt模块遵循的推荐方式,如QtSerialPort。
我通过更改以下行来修复它:
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
对这些:
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
// Qt 5 has removed them.
相关文章:
- 在Qt C++单元测试中动态加载QQuickWindow而不是QQuickWidget
- 使用Cmake将插件安装到独立的Qt Designer(不是Qt创建者)中
- Qt Designer使用Python 3.5而不是Python 3.7
- 为什么Qt资源被加载到Linux而不是Windows中?
- 应用程序仅在qt调试器中加载dll,而不是独立加载
- 文档在哪里说明如果参数不是从末端删除参数,则无法从QT信号插槽连接中删除参数?
- QT - 如何创建具有长 int(而不是 int)步长的滚动条?
- 如果不是十六进制,则QT从qlineedit中删除字符
- 为什么 Python 需要 DLL 中的 GetMessage 消息泵送,而不是 Qt
- 如何使用 qt 和 c++ 在 .bin 中编写二进制(而不是十六进制)?
- Qt. 忽略小部件中的任何鼠标事件,而不是另一个小部件
- Qt拖放在窗口中工作.我可以做到我只能放入Qlabel而不是整个窗口吗?
- QT:私人会员而不是继承?原因是什么?这是一个具体的概念吗?
- Qt C++ - 创建 QList<Myclass> - 不是参数 'T 的有效模板类型参数
- QT Quick (QML) assemble mac-.bundle -> 不是使用 macdeployqt 时的动态库错误
- 我可以使用wxWidgets而不是Qt吗?
- 我希望QT-App看起来像QT-App,而不是Android-native
- QT(4.8.2)GUI-自己的主循环,而不是qapplication :: exec()
- QT C 继续文件而不是覆盖
- Qt:VectorIterator qt不是类型