[Interest] Qt 5.4.x Android and IOS screen orientation lock in code

mark diener rpzrpzrpz at gmail.com
Fri May 15 00:59:52 CEST 2015


Hello:


I was scanning the docs and stack exchange and everywhere and could not find
an example of how to lock a screen to Portrait ONLY in Qt Code.

I tried to lock my Galaxy S2 smartphone to portrait only by issuing:

QScreen* gs = QGuiApplication::primaryScreen() ;

gs->setOrientationUpdateMask(Qt::PortraitOrientation |
Qt::InvertedPortraitOrientation) ;

But the screen still rotates.


The only thing that appears to happen is that I do not get any valid
landscape orientation information,

QScreen::orientation() only returns QT:PortraitOrientation after the
setting the mask.



And when I wanted to restore the Qt App to allow all orientations:

gs->setOrientationUpdateMask(Qt::PortraitOrientation |
Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation |
Qt::InvertedLandscapeOrientation)  ;

Now, what will NOT work is setting values and Manifest.xml or
Info.plist to universally prevent orientation changes on all
IOS/ANDROID devices.

I am only looking to lock to portrait on specific types of devices,
not all IOS/ANDROID devices.

Outside of going to the Native Android:

 public void setRequestedOrientation (int requestedOrientation)


Or Native IOS:

supportedInterfaceOrientation


Anybody have some ideas?

And of course, windows Tablets and smartphones! (That is for later)


Thanks for any responses.

md
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150514/2ba52cdd/attachment.html>


More information about the Interest mailing list