Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    [SOLVED] Qt4 Auto Rotation w/ dialogs

    Reply
    Dotblank | # 1 | 2010-06-19, 22:08 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Dotblank; 2010-06-20 at 21:23.

     
    Diph | # 2 | 2010-06-20, 07:19 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Dotblank | # 3 | 2010-06-20, 18:29 | Report

    Nope, only a progress bar

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Venemo | # 4 | 2010-06-20, 20:06 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Venemo; 2010-06-20 at 20:09.
    The Following 2 Users Say Thank You to Venemo For This Useful Post:
    Dotblank, raulh39

     
    Dotblank | # 5 | 2010-06-20, 20:53 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    raulh39 | # 6 | 2010-07-20, 17:53 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    ade | # 7 | 2011-11-05, 12:24 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout