×
Namespaces

Variants
Actions
Revision as of 04:14, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Lock application orientation in Qt for Symbian

From Nokia Developer 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 04:14.
84 page views in the last 30 days.
×