作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试将 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 用户只能在特定平台上工作,这些东西只会让 Qt 用户感到困惑,特别是如果 Qt 5 本身甚至不支持该平台。
可以在这里找到相应的 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
它比硬编码十六进制值更干净、更好。 existing Qt modules follow也是推荐的方式,比如 QtSerialPort。
关于c++ - Qt5 : error: 'WA_LockPortraitOrientation' is not a member of 'Qt' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21055734/
我是一名优秀的程序员,十分优秀!