How to Lock Application Screen Orientation in Symbian

From Qt Wiki
Revision as of 13:26, 27 April 2015 by AutoSpider (talk | contribs) (Don't #include the module prefix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
IMPORTANT: The content of this page is outdated. Reason: The Symbian platform is no longer supported.
If you have checked or updated this page and found the content to be suitable, please remove this notice.


This code snippet shows how one can have their application screen (ui) to be locked to a particular orientation (landscape or portrait mode)

In your Project profile (.pro) file

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

symbian: {

// Define UID3 for the Symbian app.
// In Qt Creator this is asked when creating an application using Mobile template.
// cone.lib, eikcore.lib and avkon.lib Symbian libraries
LIBS += -lcone -leikcore -lavkon


In your main.cpp file

#include <QApplication>

  1. include "SomeMainWindow.h"

// Needed Symbian specific headers

  1. ifdef Q_OS_SYMBIAN
  2. include <eikenv.h>
  3. include <eikappui.h>
  4. include <aknenv.h>
  5. include <aknappui.h>
  6. endif

int main(int argc, char argv[]) {

QApplication a(argc, argv);
SomeMainWindow w;
// Symbian specific code
CAknAppUi appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
TRAPD (error, 
   if (appUi) {
// Lock application orientation into landscape


return a.exec();



In the latest Qt Creator you get an option to lock the orientation as a part of the application creation wizard.