Landscape Mode



  • Well I am really new to Qt. I am develping for Nokia N8. I am designing a calculator. Everything is fine untill I rotate it in the simulator or on my device. After rotation the ui is all messed up. Is there a way to relayout the ui or better design another UI and when the device rotates it changes to the other. I cant find anywhere, how the ui looks in Landscape mode while working in DESIGNER Mode. This is important because I have some advertisement to display at the lower part from an aviation "website":http://magicofflight.com I am completely new to this. Any help appreciated. I googled it around but can only find resizing via code. Also please let me know how the orientation change is identified. If there is no way other than using code to relayout, advice me the necessary steps to make it as simple as possible. Any help is greatly appreciated and will be acknowledged. Thank You !



  • I forgot to mention. My Designing platform is Windows 7 and is using default Qt Creator 2.01



  • One generic approach to the problem is to process the "resize event":http://doc.qt.nokia.com/latest/qwidget.html#resizeEvent

    Most likely you will need to have two quite different layouts if you really want to optimize the use of the screen. Depending on your layout you may want to skip the designer and layout the components "by hand".



  • AFAIK, there is no "rotation event" (QDeskTopWidget just resizes), but due to style implementation, a StyleChanged event is raised. You might want to listen for that event.



  • As mentioned above by fcrochik make use of the resize event. Also if required you can also lock the orientation to one particular mode.



  • Thank you all for the reply. But its really really sad that you cant actually design it visually. I have like so many buttons and to position the x,y cordinate will really be boring :| . Any better way to do ? No i dont want to lock. Actually in landscape i want more buttons (some scientific options), so does that mean i have to create those buttons in realtime ? :| (P.S I am newbie)>



  • How about making a separate UI design for landscape and switch the design (the .ui file) when device rotates?



  • [quote author="oasacorp" date="1296564709"]Thank you all for the reply. But its really really sad that you cant actually design it visually. I have like so many buttons and to position the x,y cordinate will really be boring :| . Any better way to do ? No i dont want to lock. Actually in landscape i want more buttons (some scientific options), so does that mean i have to create those buttons in realtime ? :| (P.S I am newbie)> [/quote]

    Independently of the landscape/rotate issue you should try to avoid "positioning" components using arbitrary positions. The right approach is to use the Layout Classes (Vertical, Horizontal, Grid, Form) so the actual components position is calculated automatically, respecting style, fonts, skin and others.

    As someone suggested, if you really want to use the designer, you can create two separate ui files and load them using the "QUILoader":http://doc.qt.nokia.com/latest/quiloader.html



  • Thanks again. I would like to do that, as in create another ui and then load. After looking through the documentation, I realize the #include <QUiLoader> is not present :'( . Also how to trigger if its in landscape mode , shoud i compare width and height ? but how often :'(. Also please advise how to use Quiloader. By code, i did not understand Layout Classes. Any tutorials would be highly appreciated. Thank You.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.