C++ 问题5:错误:';WA#U#x27;不是';Qt';

C++ 问题5:错误:';WA#U#x27;不是';Qt';,c++,qt,symbian,qwidget,qtgui,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_AutoOrientatio

我试图将一个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'

我通过更改以下行来修复它:

#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
#如果QT_版本<0x040702
//Qt<4.7.2还没有Qt::WA_*Orientation属性
对这些:

#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.
#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.
#if(QT_版本=QT_版本检查(5,0,0))
//Qt<4.7.2还没有Qt::WA_*Orientation属性
//Qt 5已将其移除。

是的,正如您自己所指出的,在Qt 5中删除了这些

原因是这些都是Symbian独有的功能,如果Qt用户只在某个平台上工作,尤其是Qt5本身不支持该平台,那么这些功能只会让Qt用户感到困惑

相应的gerrit变化可在此处找到:

你需要更改这些行

#如果QT_版本<0x040702
//Qt<4.7.2还没有Qt::WA_*Orientation属性
对这些:

#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.
#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.
#if(QT_版本=QT_版本检查(5,0,0))
//Qt<4.7.2还没有Qt::WA_*Orientation属性
//Qt 5已将其移除。

基于Qt版本有条件地允许某些功能的好方法是:

#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
...
#endif
#if(QT_版本=QT_版本检查(5,0,0))
...
#恩迪夫
它比硬编码十六进制值更干净、更好。这也是推荐的方法,如QtSerialPort