November 29, 2010

vlad2048 vlad2048
Lab Rat
6 posts

Get screen orientation before any form created

 

Hi All

Is there any way to get current screen orientation before any form or widget created (i.e. in main.cpp after the “QApplication a(argc, argv);” line)? This is required because of the application behaves in a strange manner durring the start-up in this case: if a user clicked application icon in the portrait mode and turned the device into landscape mode, the application will still run in a portrait mode (I mean the widget sizes would be as in the portrait mode but the screen is in landscape mode, and as a result of incorrect application visualization, and this is until next orientation change).

Thanks ahead

4 replies

November 29, 2010

vlad2048 vlad2048
Lab Rat
6 posts

Please also note that my application is running in full screen mode (showFullScreen() is called).

November 29, 2010

fcrochik fcrochik
Lab Rat
517 posts

One idea: you can get the desktopWidget [doc.trolltech.com] for the application and check it’s size….

 Signature 

Certified Specialist & Qt Ambassador Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop… Qt everywhere!

November 30, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

You could also check if QOrientationReading is useful, but haven’t used it myself

November 30, 2010

fcrochik fcrochik
Lab Rat
517 posts

Just thinking out loud:

The orientation sensor will give you the physical orientation of the device. Depending on the device you may want to take other sensors into consideration. For example the auto-rotation on the n900 is disabled when the keyboard is open.

I can’t wait to experiment with it. I have used the dbus signals on the n900 to detect the device changing orientation but this would be The Qt way.

 Signature 

Certified Specialist & Qt Ambassador Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop… Qt everywhere!

 
  ‹‹ Header file missing with error "e32math.h: No such directory"      Qt bluetooth on Symbian ››

You must log in to post a reply. Not a member yet? Register here!