sas*_*alm 4 c++ qt symbian qwidget qtgui
我正在尝试将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'
Run Code Online (Sandbox Code Playgroud)
是的,正如你所说的那样,那些在Qt 5中被删除了.
原因是这些只是Symbian的功能,如果Qt用户只在某个平台上工作,这些东西就会让他们感到困惑,特别是如果Qt 5甚至不支持该平台的话.
相应的细菌变化可以在这里找到:
https://codereview.qt-project.org/#change,11280
您需要更改这些行
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
Run Code Online (Sandbox Code Playgroud)
这些:
#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.
Run Code Online (Sandbox Code Playgroud)
有条件地允许基于Qt版本的某些功能的好方法是:
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
...
#endif
Run Code Online (Sandbox Code Playgroud)
它比硬编码十六进制值更清晰,更好.它也是现有Qt模块遵循的推荐方式,如QtSerialPort.