Search code examples
qtsymbian

How to lock the application orientation to portrait in 4.6.3


I would like to restrict my application to portrait orientation. I was able to it in Qt 4.7.3 but was unable use the same code for Qt 4.6.3. Is there any way to setOreintation in Qt 4.6.3


Solution

  • You can use Symbian specific code to meet your requirement. Add the following code in your Main.cpp file:

    // Symbian specific code
        #ifdef Q_OS_SYMBIAN
        CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
        TRAPD(error, 
        if (appUi) {
            // Lock application orientation into Portrait
            appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
        }
        );
        #endif
    

    Also the following LIBS in your pro file:

    LIBS += -lcone -leikcore -lavkon
    

    Refer this LINK for more details.