Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Handling Screen Orientation with Qt

    Reply
    mtrower2 | # 1 | 2011-06-23, 22:07 | Report

    I am able to detect when the screen orientation changes without any issues. I am wondering what the best way to make your application "rotation-friendly" is using Qt.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to mtrower2 For This Useful Post:
    Tiboric

     
    marxian | # 2 | 2011-06-23, 22:24 | Report

    The way I did it is to connect a slot to the QApplication::desktop()->resized() signal. In this slot, you can reorder the widgets depending on whether the application is in portrait mode (height > width) or landscape mode (width > height). You can reorder the widgets by calling the resize() or setGeometry() methods as appropriate (use resize() where possible).

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to marxian For This Useful Post:
    mtrower2, Tiboric

     
    mtrower2 | # 3 | 2011-06-24, 01:38 | Report

    @marxian, thanks for this tip. I am having issues getting the widgets to use the entire vertical space when in portrait mode. Is there some widget which controls this? I have tried using this->setGeometry and ui->centralWidget->resize.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    xerxes2 | # 4 | 2011-06-24, 14:42 | Report

    Anyone knows how to force landscape mode?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    mtrower2 | # 5 | 2011-06-24, 15:37 | Report

    Originally Posted by xerxes2 View Post
    Anyone knows how to force landscape mode?
    Something like this (in main() before you show the form):

    #ifdef Q_WS_MAEMO_5
    w.setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
    #endif

    src: http://doc.qt.nokia.com/qt-maemo/maemo5-rotation.html

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to mtrower2 For This Useful Post:
    xerxes2

     
    xerxes2 | # 6 | 2011-06-24, 18:03 | Report

    Thanks man, but I was thinking for meego/harmattan. On Fremantle I'd think landscape is default as I've never heard of any complaints about it.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    xerxes2 | # 7 | 2011-06-29, 20:20 | Report

    Found the answer for meego: http://forum.meego.com/archive/index.php/t-2958.html

    Edit | Forward | Quote | Quick Reply | Thanks

     
    xerxes2 | # 8 | 2011-07-03, 16:57 | Report

    That might not work on Meego I just found out.
    http://forum.meego.com/showthread.php?t=3692

    Will test and report back asap when I get the device.

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout