×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Regular Contributor
    Join Date
    May 2009
    Posts
    146

    Lock orientation

    Hi!

    I need to run my application in portrait mode only. How can I lock the orientation mode to portrait using only Qt? (no native c++ as I can't get it to work with Qt Creator)

    Thanks!

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

    Re: Lock orientation

    Hi,

    Currently, you can't, you'll have to do it like this. Can you specify what problems you're having with that method?

  3. #3
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: Lock orientation

    AFAIK its not possible. Qt still depends upon Symbian Native calls.

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

    Re: Lock orientation

    Quote Originally Posted by treinio View Post
    Hi,

    Currently, you can't, you'll have to do it like this. Can you specify what problems you're having with that method?
    You can't use any Symbian interfaces with the new fancy-dancy Qt Creator kit.

  5. #5
    Regular Contributor
    Join Date
    May 2009
    Posts
    146

    Re: Lock orientation

    Quote Originally Posted by treinio View Post
    Hi,

    Currently, you can't, you'll have to do it like this. Can you specify what problems you're having with that method?
    The problem is that I can't use the c++ stuff in Qt Creator. So I get errors when trying to use the libraries. As it seems to be impossible to lock orientation mode with Nokia Qt SDK my idea is now to build using carbide and qt 4.6.3 + smart installer instead and hopefully Ovi Store will accept my application anyway.
    Last edited by stegemann; 2010-06-29 at 14:40.

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

    Re: Lock orientation

    Hmm..I'm confused. We're talking about Qt Creator that comes with Nokia Qt SDK? Surely you can use native Symbian code, the Symbian SDK is integrated into the thing. Or maybe you mean that you can't use Symbian C++ APIs when building for Qt Simulator target? That would be true, because the simulator is a win32 target, with some cosmetics slapped on to help it masquerade as a mobile phone when run.

    But as long as you use Q_OS_SYMBIAN #ifdef's around your Symbian-specific code and in .pro file add the libraries inside symbian scope (as in the article), it should work when building for Symbian device target.

  7. #7
    Regular Contributor
    Join Date
    May 2009
    Posts
    146

    Re: Lock orientation

    Quote Originally Posted by treinio View Post
    Hmm..I'm confused. We're talking about Qt Creator that comes with Nokia Qt SDK? Surely you can use native Symbian code, the Symbian SDK is integrated into the thing.
    Yes exactly that Qt Creator. I made a clean install of the NokiaQtSDK and when trying to add the libs that I need to lock orientation I get errors. It works perfect when I do the same thing in Carbide. And the problem is not with the Simulator it is the device. Have you got it working yourself? Pleaes explain how to do it. Thanks!

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

    Thumbs up Re: Lock orientation

    Quote Originally Posted by stegemann View Post
    Have you got it working yourself? Pleaes explain how to do it. Thanks!
    Seems to work OK for me.

    main.cpp

    Code:
    #include <QtGui/QApplication>
    #include <QMainWindow>
    
    #ifdef Q_OS_SYMBIAN
    #include <AknAppUi.h>
    #endif
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        
        // Lock orientation to landscape on Symbian platform
    #ifdef Q_OS_SYMBIAN
    
        CAknAppUi* appUi = dynamic_cast<CAknAppUi*>( CEikonEnv::Static()->AppUi() );
          
        if(appUi) 
          {
          TRAP_IGNORE( appUi->SetOrientationL( CAknAppUi::EAppUiOrientationLandscape ) );
          }
                          
    #endif // Q_OS_SYMBIAN
    
        QMainWindow w;
        w.setWindowFlags( w.windowFlags() ^ Qt::WindowSoftkeysVisibleHint );
        w.showFullScreen();
        return a.exec();
    }
    .pro

    Code:
    TEMPLATE = app
    TARGET = lock_orientation
    
    SOURCES += main.cpp
    
    symbian: LIBS += -lcone -leikcore -lavkon
    Try the above code - if it doesn't compile, post whatever error messages you get here!

  9. #9
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    73

    Re: Lock orientation

    Hi Guys
    The code snippet works very well for me. Is it also possible to lock the orientation of single widgets? I have multiple widgets in my app and like to have some be able to change the orientation, others not.

    Cheers, Luki

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    25

    Re: Lock orientation

    Unfortunatelly I got problems with using the example code you guys are dicussing.


    /NokiaQtSDK/Symbian/SDK/EPOC32/BUILD/dev/qt/QtGfx/QTGFX_0XEF7F5933/GCCE/UDEB/main.o: In function `main':

    /dev/qt/QtGfx/main.cpp:58: undefined reference to `CAknAppUiBase::SetOrientationL(CAknAppUiBase::TAppUiOrientation)'

    /dev/qt/QtGfx/main.cpp:101: undefined reference to `typeinfo for CCoeAppUi'

    /dev/qt/QtGfx/main.cpp:101: undefined reference to `typeinfo for CAknAppUi'

    /NokiaQtSDK/Symbian/SDK/EPOC32/BUILD/dev/qt/QtGfx/QTGFX_0XEF7F5933/GCCE/UDEB/main.o: In function `CEikonEnv::Static()':

    /NokiaQtSDK/Symbian/SDK/epoc32/include/eikenv.inl:15: undefined reference to `CCoeEnv::Static()'

    make[2]: *** [\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb\QtGfx.exe] Error 1

    make[1]: *** [TARGETQTGFX_0XEF7F5933] Error 2

    Please help.

    M.

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    25

    Re: Lock orientation

    After switching compilation to release mode the code snippet works for me too.
    It looks like we can't use it in debug mode though.

    I'm using NokiaQtSDK 1.0

    M.

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

    Re: Lock orientation

    Under Carbide you can compile it either way. But it may be that the Nokia Qt SDK can't hack that (it can barely manage Symbian code at all).

    Or it may be that you just have a problem with your debug mode configuration.

  13. #13
    Registered User
    Join Date
    Nov 2010
    Posts
    79

    Re: Lock orientation

    (Lock orientation code)it is not working can you send me your code in zip formate
    at this email
    amitsharma@cdnsol.com

Similar Threads

  1. Controlling Num Lock and Caps Lock Icon Display
    By pgarofalo in forum Symbian
    Replies: 1
    Last Post: 2010-04-21, 00:23
  2. Orientation
    By alhad41 in forum Symbian
    Replies: 4
    Last Post: 2009-08-11, 10:41
  3. portrait orientation and landscape orientation in N96
    By videoFx in forum [Archived] Flash Lite on Nokia Devices
    Replies: 0
    Last Post: 2009-05-20, 15:13
  4. Orientation changes ?
    By David Makin in forum Symbian
    Replies: 7
    Last Post: 2008-02-10, 19:14
  5. Nokia forward-lock and OMA v1.0 forward-lock
    By fausti in forum Digital Rights Management & Content Downloading
    Replies: 0
    Last Post: 2003-03-18, 10:11

Posting Permissions

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