×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    16

    Question How to set Orientation(Portrait/Lanscape) of Qt app ?

    Hi
    I am running my Qt app on 5800, I need to set orientation of my Qt app to portrait irrespective of device's orientation. For this I used setOrientation(Qt::Vertical), but no use.

    Please help me to find out how we can do it.

    Thanks in advance
    Sumit

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    10

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    Hi,

    Qt originally being developed for desktop use, I'm not sure if the current API provides support for such a thing at all. Hopefully someone will correct me if I'm wrong here.

    There is an example application in the Wiki which shows a workaround:

    http://wiki.forum.nokia.com/index.ph...ower_of_S60_Qt

    Here's a piece of code from its main.cpp:

    // lock orientation
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
    if(appUi){
    appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
    }

    I haven't actually tried whether that works as expected, but I guess it's worth a try Perhaps this kind of functionality will be made available in a proper way in the Mobile Extensions package one day...

    Cheers,

    - Petri

  3. #3
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    I use this snipped in all of my test programms. It works. However, add some includes:

    #include <eikenv.h>
    #include <eikappui.h>
    #include <aknenv.h>
    #include <aknappui.h>

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    Quote Originally Posted by sumitsasken View Post
    I am running my Qt app on 5800, I need to set orientation of my Qt app to portrait irrespective of device's orientation. For this I used setOrientation(Qt::Vertical), but no use.
    setOrientation(Qt::Vertical) of which class?? i dont think any Qt specific class have that function.


    As said by niemi23, CAknAppUi::SetOrientationL() API of symbian is working fine.

  5. #5
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    81

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    A reminder to the folks coding in Qt: The SetOrientationL call needs to be surrounded by some sort of TRAP, most commonly a QT_TRAP_THROWING.

    Quote Originally Posted by niemi23 View Post
    Hi,

    Qt originally being developed for desktop use, I'm not sure if the current API provides support for such a thing at all. Hopefully someone will correct me if I'm wrong here.

    There is an example application in the Wiki which shows a workaround:

    http://wiki.forum.nokia.com/index.ph...ower_of_S60_Qt

    Here's a piece of code from its main.cpp:

    // lock orientation
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
    if(appUi){
    appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
    }

    I haven't actually tried whether that works as expected, but I guess it's worth a try Perhaps this kind of functionality will be made available in a proper way in the Mobile Extensions package one day...

    Cheers,

    - Petri

  6. #6
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    Can you give a complete piece of code? Yesterday I tried to compile an application that uses such calls to lock orientation agains Qt 4.6.0. The app crashes in that call. It did not crash with the 4.5 tech preview. May it work again with this trap added?

  7. #7
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?


  8. #8
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    Thank you, it works again.

  9. #9
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    81

    Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    I've experimented with the SetOrientationL interface a bit. It works somewhat raggedly on the emulator, but pretty robustly on a real N97. I can switch between portrait and landscape and back, contradicting the "advice" from the accelerometers. I find, though, that once it's been set to portrait or landscape, setting "Automatic" or "Unspecified" does not appear to restore accelerometer-based selection.

  10. #10
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    81

    Unhappy Re: How to set Orientation(Portrait/Lanscape) of Qt app ?

    I apparently spoke too soon. On an N97, if you switch back and forth between landscape and portrait a (random) number of times (I'd say anywhere between 5 and 15), the touch screen slowly becomes less and less sensitive, until eventually it won't honor any of your buttons (though the Exit button still seems as sensitive as ever).

    This seems to happen, though, even if you just auto-rotate the screen a bunch of times, although I can't reproduce that behavior with another toy application I have, so I suppose it could somehow relate to my screen switching lashup.

Similar Threads

  1. How to Set Orientation of S60 App?
    By vivekg79 in forum Symbian
    Replies: 4
    Last Post: 2009-03-10, 08:03
  2. Set QualityFactor in camera app for N958G
    By aefr123 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-02-05, 15:53
  3. Replies: 27
    Last Post: 2008-10-19, 21:23
  4. how i can set Open menu in my app
    By 1symbian1 in forum Symbian
    Replies: 5
    Last Post: 2008-10-09, 13:36
  5. Set the app to run in background from code
    By symsym in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-10-29, 17:40

Posting Permissions

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