【问题标题】:Qt5: error: 'WA_LockPortraitOrientation' is not a member of 'Qt'Qt5:错误:“WA_LockPortraitOrientation”不是“Qt”的成员
【发布时间】:2014-01-10 22:36:07
【问题描述】:

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

【问题讨论】:

    标签: c++ qt symbian qwidget qtgui


    【解决方案1】:

    是的,正如您自己所说,这些已在 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。

    【讨论】:

      【解决方案2】:

      我通过更改这些行来修复它:

      #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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-23
        • 2014-03-09
        • 2020-02-02
        • 2014-08-27
        • 2016-02-15
        • 2021-09-07
        相关资源
        最近更新 更多