How to Lock Application Screen Orientation in Symbian: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Don't #include the module prefix)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Outdated|reason=The Symbian platform is no longer supported.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
= Overview =
= Overview =


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


<code>symbian: {<br /> // Define UID3 for the Symbian app.<br /> // In Qt Creator this is asked when creating an application using Mobile template.<br /> TARGET.UID3 = 0xSOMEUID<br /> // cone.lib, eikcore.lib and avkon.lib Symbian libraries<br /> LIBS += -lcone -leikcore -lavkon<br />}</code>
<code>symbian: {
<br />In your main.cpp file
// Define UID3 for the Symbian app.
<br /><code>#include <QtGui/QApplication><br />#include "SomeMainWindow.h"
// In Qt Creator this is asked when creating an application using Mobile template.
<br />// Needed Symbian specific headers<br />#ifdef Q_OS_SYMBIAN<br />#include <eikenv.h><br />#include <eikappui.h><br />#include <aknenv.h><br />#include <aknappui.h><br />#endif
TARGET.UID3 = 0xSOMEUID
<br />int main(int argc, char '''argv[])<br />{<br /> QApplication a(argc, argv);
// cone.lib, eikcore.lib and avkon.lib Symbian libraries
<br /> SomeMainWindow w;
LIBS += -lcone -leikcore -lavkon
<br /> // Symbian specific code<br /> #ifdef Q_OS_SYMBIAN<br /> CAknAppUi''' appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());<br /> TRAPD (error,  
}</code>
     if (appUi) {<br /> // Lock application orientation into landscape<br /> appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);<br /> }<br /> );<br /> #endif
 
In your main.cpp file
 
<code>#include <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();<br /> return a.exec();<br />}</code>
w.showFullScreen();
return a.exec();
}</code>


===== Note =====
===== Note =====


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

Latest revision as of 13:26, 27 April 2015

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 article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

Overview

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.
 TARGET.UID3 = 0xSOMEUID
 // cone.lib, eikcore.lib and avkon.lib Symbian libraries
 LIBS += -lcone -leikcore -lavkon
}

In your main.cpp file

#include <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();
}
Note

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