Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Lock application orientation in Qt for Symbian

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The example illustrated here uses the avkon libraries and was recommended until Qt 4.7.1. From Qt 4.7.1 you can instead use the instructions in Archived:Lock application orientation in Qt.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QApplication, CAknAppUi, EAppUiOrientationLandscape
Created: tepaa (20 Oct 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

This example shows how to lock the application orientation.


Preconditions

  • Qt is installed on your platform.
    • Download Qt release from here: [1]


Qt project file

You must add the cone.lib, eikcore.lib, and avkon.lib Symbian libraries into the Qt build for orientation handling.

symbian: { 
// Define UID3 for the Symbian app.
// Qt 4.6 beta release force to define that.
TARGET.UID3 = 0xSOMEUID
// cone.lib, eikcore.lib and avkon.lib Symbian libraries
LIBS += -lcone -leikcore -lavkon
}


Source

Here is an example of a Qt application main.cpp source file where the application orientation is locked into landscape.

#include <QtGui/QApplication>
#include "SomeMainWindow.h"
 
// Needed Symbian specific headers
#ifdef Q_OS_SYMBIAN
#include <eikenv.h>
#include <eikappui.h>
#include <aknenv.h>
#include <aknappui.h>
#endif
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
 
SomeMainWindow w;
 
// Symbian specific code
#ifdef Q_OS_SYMBIAN
CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
TRAPD(error,
if (appUi) {
// Lock application orientation into landscape
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
}
);
#endif
 
w.showFullScreen();
return a.exec();
}


Postconditions

The application orientation is landscape, and it does not change even if the device orientation is changed by the user.

This page was last modified on 11 October 2012, at 01:14.
56 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×