Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt5: error: 'WA_LockPortraitOrientation' is not a member of 'Qt'

I'm trying to compile a Qt4/Symbian project to Qt5, while preserving support for Qt4/Symbian.

Currently the MainWindow::setOrientation auto-generated boilerplate function is giving me trouble.

It gives me these compiler errors:

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'
like image 790
sashoalm Avatar asked Mar 22 '23 00:03

sashoalm


2 Answers

Yes, those were removed in Qt 5 as you noted yourself.

The reason is that these are Symbian-only features and such things just confuse the Qt users if they only work on a certain platform, especially if that platform is not even supported by Qt 5, inherently.

The corresponding gerrit change can be found in here:

https://codereview.qt-project.org/#change,11280

You need to change these lines

#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes

to these:

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

The nice way for conditionally allowing certain features based on the Qt version would be this:

#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 2)) || (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
...
#endif

It is cleaner and nicer than hard-coding hex values. It is also the recommended way that existing Qt modules follow, like QtSerialPort.

like image 110
lpapp Avatar answered Apr 26 '23 13:04

lpapp


I fixed it by changing these line:

#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes

to these:

#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.
like image 20
sashoalm Avatar answered Apr 26 '23 12:04

sashoalm