Reply
Thread Tools
Posts: 94 | Thanked: 253 times | Joined on Jan 2010 @ Virginia
#1
I seem to be having an issue with auto-rotation not affecting dialogs or other widgets immediately.

Following the concept in this example for qt4
http://doc.trolltech.com/qt-maemo-4....-rotation.html

I have implemented a widget that has auto-rotation. That works and performs fine but when I create a dialog window the rotation is almost random.

When the dialog pops up sometimes it rotates back into landscape and after a small period of time if you re-rotate the n900 it rotates the dialog back to portrait. I have tried getting around this but the only workaround would be me implementing the sensors api in qt mobility.

I have to set the dialog widget attribute to WA_Maemo5AutoOrientation otherwise it is always landscape mode.

I think the issue is that when a widget gets the auto rotation flag set it re-initializes the accelerometer taking time and defaults to landscape when it doesn't have any data from the sensor yet.

Last edited by Dotblank; 2010-06-20 at 21:23.
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#2
Do you have text input labels in dialogs? In that case I think it changes back to landscape because you can't use keyboard in portrait mode.
 
Posts: 94 | Thanked: 253 times | Joined on Jan 2010 @ Virginia
#3
Nope, only a progress bar
 
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#4
Originally Posted by Dotblank View Post
I seem to be having an issue with auto-rotation not affecting dialogs or other widgets immediately.

Following the concept in this example for qt4
http://doc.trolltech.com/qt-maemo-4....-rotation.html

[...]

I have to set the dialog widget attribute to WA_Maemo5AutoOrientation otherwise it is always landscape mode.

I think the issue is that when a widget gets the auto rotation flag set it re-initializes the accelerometer taking time and defaults to landscape when it doesn't have any data from the sensor yet.
Hi!

Actually, the auto rotation in Qt has a bug (QtBug 11190) that makes it work incorrectly.

For a working auto-rotation sample, check out the QMaemo5Rotator class in my repo. (header, cpp)

Just copy-paste the code files. It is dead easy to use.

Code:
QMaemo5Rotator *rotator = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior, this);
You can change its behaviour in runtime.

Last edited by Venemo; 2010-06-20 at 20:09.
 

The Following 2 Users Say Thank You to Venemo For This Useful Post:
Posts: 94 | Thanked: 253 times | Joined on Jan 2010 @ Virginia
#5
Originally Posted by Venemo View Post
Hi!

Actually, the auto rotation in Qt has a bug (QtBug 11190) that makes it work incorrectly.

For a working auto-rotation sample, check out the QMaemo5Rotator class in my repo. (header, cpp)

Just copy-paste the code files. It is dead easy to use.

Code:
QMaemo5Rotator *rotator = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior, this);
You can change its behaviour in runtime.
Fantastic. I got this working and is exactly what I needed
 
Posts: 2 | Thanked: 0 times | Joined on Jul 2010
#6
Hello,

Thank you for the information and for the QMaemo5Rotator class

But I think I have found a bug in this class: if you set automatic mode and then you want to set portrait (or landscape mode), it will keep sending the signal orientationChanged whenever you move the phone.

That is, whenever you do:
Code:
rotator = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior, this);
all attempts to set another behavior, like
Code:
rotator->setCurrentBehavior(QMaemo5Rotator::PortraitBehavior);
will not work as I expect it. The signal orientationChanged keeps getting emitted.

This happens because on_orientation_changed() stills gets called when you move the phone because you don't disconnect it from QDBusConnection::systemBus() in the setCurrentBehavior function.

As a workaround, I have added this line as the first line in QMaemo5Rotator:: on_orientation_changed:
Code:
if(_currentBehavior != QMaemo5Rotator::AutomaticBehavior) return;
Maybe I don't fully understand how it is supposed that I have to use the class. I am newbie to this.

Hope this helps,
Raul.
 
Posts: 1,100 | Thanked: 2,797 times | Joined on Apr 2011 @ Netherlands
#7
I face the problem that, when I open a shared library in a program, it always switches to landscape.

More detailed:
Using QMaemo5Rotator as mentioned in this post for rotation.
If I open the shared library to set date and time (libcpdatetime.so):
Code:
osso_context_t *osso;
osso = osso_initialize("appname", "", TRUE, NULL);
osso_cp_plugin_execute(osso, "libcpdatetime.so", this, TRUE);
it shows the date/time dialog, but always jumps to landscape.
The CSSU version of the control panel / settings also uses this shared library if you choose "date and time", but in that case it autorotates like I want to. Unfortunally for me, this program is made in GTK, not QT, so the source is not that helpfull.

Any suggestions how to make autorotate work here?
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 05:00.