Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
How to Lock Application Screen Orientation in Symbian: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
=Overview= | = Overview = | ||
This code snippet shows how one can have their application screen (ui) to be locked to a particular orientation (landscape or portrait mode) | 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 | 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. | You must add the cone.lib, eikcore.lib, and avkon.lib Symbian libraries into the Qt for S60 build for orientation handling. | ||
In your main.cpp file | <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 <s>lavkon<br />}</code> | ||
<br />In your main.cpp file | |||
<br /><code>#include <QtGui/QApplication&gt;<br />#include "SomeMainWindow.h&quot; | |||
<br />// Needed Symbian specific headers<br />#ifdef Q_OS_SYMBIAN<br />#include <eikenv.h&gt;<br />#include <eikappui.h&gt;<br />#include <aknenv.h&gt;<br />#include <aknappui.h&gt;<br />#endif | |||
<br />int main(int argc, char '''argv[])<br />{<br /> QApplication a(argc, argv); | |||
<br /> SomeMainWindow w; | |||
<br /> // Symbian specific code<br /> #ifdef Q_OS_SYMBIAN<br /> CAknAppUi''' appUi = dynamic_cast&lt;CAknAppUi*> (CEikonEnv::Static()</s>>AppUi());<br /> TRAPD (error, | |||
if (appUi) {<br /> // Lock application orientation into landscape<br /> appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);<br /> }<br /> );<br /> #endif | |||
=====Note===== | w.showFullScreen();<br /> return a.exec&amp;#40;&#41;;<br />}</code> | ||
===== 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. |
Revision as of 11:37, 24 February 2015
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&#41; file
You must add the cone.lib, eikcore.lib, and avkon.lib Symbian libraries into the Qt for S60 build for orientation handling.
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 <s>lavkon<br />}
In your main.cpp file
#include <QtGui/QApplication&gt;<br />#include "SomeMainWindow.h&quot;
<br />// Needed Symbian specific headers<br />#ifdef Q_OS_SYMBIAN<br />#include <eikenv.h&gt;<br />#include <eikappui.h&gt;<br />#include <aknenv.h&gt;<br />#include <aknappui.h&gt;<br />#endif
<br />int main(int argc, char '''argv[])<br />{<br /> QApplication a(argc, argv);
<br /> SomeMainWindow w;
<br /> // Symbian specific code<br /> #ifdef Q_OS_SYMBIAN<br /> CAknAppUi''' appUi = dynamic_cast&lt;CAknAppUi*> (CEikonEnv::Static()</s>>AppUi());<br /> TRAPD (error,
if (appUi) {<br /> // Lock application orientation into landscape<br /> appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);<br /> }<br /> );<br /> #endif
w.showFullScreen();<br /> return a.exec&amp;#40;&#41;;<br />}
Note
In the latest Qt Creator you get an option to lock the orientation as a part of the application creation wizard.