gpt4 book ai didi

c++ - Qt5 : error: 'WA_LockPortraitOrientation' is not a member of 'Qt'

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:29:22 26 4
gpt4 key购买 nike

我正在尝试将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com