×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    portrait / landscape mode in application

    hi,

    I've implemented an application and want to make it possible to view it either in portrait or landscape mode, now when you change the device orientation some buttons or other object are out of the visible area and you need to rotate 2 times so as to get in the visible area (only if their is enough room).

    I tried something like PLLayout but still some things go out of the visible area. My Application has a QMainWindow and when I navigate from one view to the next and back I change the centralWidget with method setCentralWidget and put my classes instances of QWidget. Is there any way to make that work? I would prefer a method thats allows to change the layout in order to rearrange the order of some buttons etc.

    thanks

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: portrait / landscape mode in application

    You probably do something wrong with layouts or sizeHints/policies.

  3. #3
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    Re: portrait / landscape mode in application

    I didn't change or set anyware sizeHints/policies, so there are the default and it seems that there is enough room for all objects.

    Having print the event.size() inside all my resizeEvent methods and compare it with QRect qs=QApplication::desktop()->availableGeometry(); the PLLayout has at its resizeEvent to understand if its portrait or landscape mode I find out that the different (319) makes the problem

    Code:
    QSize(502, 319)  : MainWindow
    QSize(502, 319)  : Widget
    QSize(502, 319) : PLLayout (event) 
    QSize(502, 288) : PLLayout (availableGeometry) 
    QSize(360, 487)  : Widget
    QSize(360, 487) : PLLayout (event) 
    QSize(360, 487) : PLLayout (availableGeometry) 
    QSize(360, 487)  : MainWindow
    QSize(502, 319)  : Widget
    QSize(502, 319) : PLLayout (event) 
    QSize(502, 288) : PLLayout (availableGeometry) 
    QSize(502, 319)  : MainWindow
    i can't really understand why that happens as i paid attention in auto layout to put first the
    autoLayout->setLLayout(layoutLandscape); and then autoLayout->setPLayout(layoutPortrait); as the example insisted... is that some-kind of a bug?

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: portrait / landscape mode in application

    Let me guess that one of the controls has something to do with calendars?
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  5. #5
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    Re: portrait / landscape mode in application

    No, I don't have any calendar in widget...

    There is a QMainWindow, that has noting inside except en empty QWidget at its center.
    And at the place of that center widget I put a menu that i have design with an image up (in a label) and 5 buttons under that if its portrait and when terns landscape I put the image at the right side and the buttons next to it.

    An other problem find out was that putting the application in the mobile device everything looks terrible... nothing was at the same position as it looks at the simulator :S
    all the upper side buttons/labels etc was under the "menubars" of the phone and the turning not works properly also

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: portrait / landscape mode in application

    Quote Originally Posted by mando7stam View Post
    An other problem find out was that putting the application in the mobile device everything looks terrible... nothing was at the same position as it looks at the simulator :S
    all the upper side buttons/labels etc was under the "menubars" of the phone and the turning not works properly also
    Welcome to the world of "smart" phone programming.

  7. #7
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: portrait / landscape mode in application

    Hi.
    if you dont have calendars (known trouble makers), the situation gets interesting.

    Could you post some screenshots maybe?

    Tam
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  8. #8
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    Re: portrait / landscape mode in application

    When on portrait

    quite ok, but you the buttons were small... i tried Extended state in buttons but nothing changed, the picture was completely the same!!!

    and on landscape

    the last button cuts ... although there could start upper all the buttons and get in the screen it not.

    Tried: Setting the buttons in extended state make also the last one cut. Here the extension works and fills the inside area of the buttons with them.

    Also i tried to change manually the resize event with available geometry in both resize events:

    In my MainWindow which contains the Widget Class:
    Code:
    void WeatherGR::resizeEvent (QResizeEvent* event)
    {
        QRect qs = QApplication::desktop()->availableGeometry();
        QSize widgetSize = qs.size();//event->size();
    
        setWidgetGeometry(&widgetSize);
        if( event->size() != qs.size())
            event = new QResizeEvent(qs.size(), event->oldSize());
    
        QMainWindow::resizeEvent(event);
    }
    In my Widget Class with the buttons:
    Code:
    void Menu::resizeEvent (QResizeEvent* event)
    {
        QRect qs = QApplication::desktop()->availableGeometry();
        if( event->size() != qs.size())
            event = new QResizeEvent(qs.size(), event->oldSize());
        // Call the autoLayout convenience function for the event handling
        autoLayout->resizeEvent(event);
    
        // Call base class resize event handler
        QWidget::resizeEvent(event);
    }
    but no change either ... cannot really understand why... the source seems to be OK
    putting into the device things get worse... if you have it sticked on portrait mode everything is great
    BUT when you decide to turn it landscape more of the down right objects get out of visible area... turning again portrait you still view the landscape view!

  9. #9
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: portrait / landscape mode in application

    Hi,
    I infer from the screenshot above that the widget is "greedy".

    Have you tried to set a minimumSize height to the buttons?

    All the best
    Tam Hanna
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  10. #10
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    Wink Re: portrait / landscape mode in application

    no i hadn't use it cause i didn't know the size of the buttons as depends to device and to portrait / landscape mode...

    trying to set the minimum size whenever the orientation changes i come up with the idea to resize each button separately and with the combination of extended state it fixed. Simulator works great! but device has 2 problems
    - the orientation still is confusing on turning on portrait mode after 2 rotations appears the landscape mode... like after a run the rotating code stop working/executing [FIXED]
    - if it starts on portrait the buttons mixed with mobiles buttons Exit / Options * [FIXED]

    I'm checking the source once again...

    Edit: * should that buttons and operators/battery etc appear in full screen mode?
    having set it to run:
    Code:
    #if defined(Q_WS_S60)
        w->showMaximized();
    #else
        w->show();
    #endif
    Edit 2: fixed the 2 problems
    and as i seen there is also a fullscreen mode except maximized so thats also ok!!!

    thanks a lot!
    Last edited by mando7stam; 2010-07-22 at 12:01.

  11. #11
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: portrait / landscape mode in application

    Hi,
    I am sorry, but I lost you here.

    Do you still have open questions?

    All the best
    Tam Hanna
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  12. #12
    Registered User
    Join Date
    Jun 2010
    Location
    Athens, Greece
    Posts
    65

    Re: portrait / landscape mode in application

    I finally fixed the menu, and works great in simulator and device too!
    I moved to the next screen with some similar problems hopping to figure them out in a similar way.

    So, I may come back from Monday... for the time being have a nice weekend!!!

    thanks a lot!

  13. #13
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: portrait / landscape mode in application

    Hi,
    ok - we'll be waiting.

    All the best
    Tam Hanna
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  14. #14
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Romania, Cluj-Napoca
    Posts
    82

    Re: portrait / landscape mode in application

    Hello!

    Another question related to PLLayout.
    I have the following problem:
    When I change the orientation of the phone, for ex from landscape to portrait, after the size change, first all the controls appear from the portrait layout, and after 1-2 seconds, they the new layout is activated.
    The annoying thing is the 1-2 sec delay.
    Anybody experienced the same with PLLayout?
    Uploaded a screen capture: http://www.megafileupload.com/en/fil...ayout-avi.html

    Gr3go

  15. #15
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: portrait / landscape mode in application

    It's only simulator and experience on real device might be dramatically different.

Similar Threads

  1. Observer handle for portrait/landscape mode???
    By carsamba55 in forum Mobile Java General
    Replies: 5
    Last Post: 2010-02-16, 16:09
  2. Portrait/Landscape mode switch
    By batora in forum Mobile Java General
    Replies: 4
    Last Post: 2010-02-10, 09:05
  3. Stop Switching from Portrait to Landscape mode
    By Ashish Gupta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2009-06-30, 10:04
  4. Supporting landscape/Portrait mode
    By gpalvia in forum Symbian User Interface
    Replies: 4
    Last Post: 2009-01-30, 08:50
  5. Screen Mode from portrait to landscape
    By rami75lu in forum Symbian User Interface
    Replies: 0
    Last Post: 2008-10-15, 04:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×