×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    22

    How to lock screen orientation

    I want to lock screen orientation in portrait mode. I used setAttribute(Qt::WA_LockPortraitOrientation) method in form, main but I couldn't lock screen orientation. When I ran the program, I clicked on emulator's screen orientation button. It rotated immediately.
    Please help me.

  2. #2
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,357

    Re: How to lock screen orientation

    you can try this in main.cpp
    Code:
    #ifdef Q_OS_SYMBIAN
        // lock screen orientation
    
        CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
        if(appUi){
            QT_TRAP_THROWING(appUi ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
        }
    
    #endif
    Last edited by somnathbanik; 2011-06-10 at 07:25. Reason: added

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

    Re: How to lock screen orientation

    But you need some includes and libs.

    And note that it won't work on the simulator.

  4. #4
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,357

    Re: How to lock screen orientation

    yes as mentioed by danhicksbyron, you need to add the header and libs
    Code:
    #ifdef Q_OS_SYMBIAN
    #include <eikenv.h>
    #include <eikappui.h>
    #include <aknenv.h>
    #include <aknappui.h>
    #endif
    .pro
    Code:
    symbian {
    LIBS += -lcone -leikcore -lavkon
    }
    Last edited by somnathbanik; 2011-06-10 at 13:30. Reason: added

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    9

    Re: How to lock screen orientation

    I've had the same problems, I want my app to lock in landscape. I've tried the steps in this thread and a few other but it doesn't seem to help.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    9

    Re: How to lock screen orientation

    SOLVED

    Can anyone help me?

    I still havent solved the issue with my app. I've tried every combination of the examples for Locking screen orientation but they don't seem to work for my app. Does it work only for widgets or mainwindow too?

    I've built a couple of example projects for N8 which both use the same code as I have to lock orientation and they seem to work with same settings and build targets.

    Any ideas?

    Solution:
    So if you have QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes); in your project.. it doesn't seem to work use showFullScreen in all widgets etc instead of that attribute.
    Last edited by akse; 2011-07-08 at 11:20. Reason: solved

  7. #7
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    183

    Re: How to lock screen orientation

    Can you add additional details of your app?
    Do you get resize events when it should be locked?

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    9

    Re: How to lock screen orientation

    Quote Originally Posted by Fuzzbender View Post
    Can you add additional details of your app?
    Do you get resize events when it should be locked?
    Don't worry I got it working already, but thanks. It was the attribute that somehow forced rotation to auto. I actually am able to use the Qt specific orientation code now, don't need symbian native.

  9. #9
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    183

    Re: How to lock screen orientation

    Ah, right. The native side (AVKON) needs StatusPane component for rotation support (or locking). Using QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes) means that Qt app won't create any native panes, which means that any native feature support requiring those is also removed. This native limitation should perhaps be documented to the Qt application attributes.

Similar Threads

  1. how to lock orientation in meego with QT
    By linlin_0 in forum Nokia N9
    Replies: 3
    Last Post: 2010-11-16, 08:57
  2. How to decide screen orientation awareness?
    By raj_rr7 in forum Symbian Media (Closed)
    Replies: 9
    Last Post: 2009-07-03, 15:21

Posting Permissions

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