From Forum Nokia Wiki
Summary: This article describes how to force the use of a horizontal or vertical screen in the QT for Symbian program even when the phone's horizontal status is changed.
For Symbian phones with a horizontal sensor, when the user switches the phone from landscape mode (Landscape) to vertical screen mode (Portrait), the screen orientation of the phone is automatically adjusted to meet the user's normal usage needs. Changes in the aspect ratio of the screen require the layout of the adjustment window to be applied to ensure a better user experience.
However, in some special occasions (such as games), the developer may want to even if the phone's horizontal status has changed, need to continue to maintain the screen orientation, prompting the user to use the current application only in the horizontal or vertical screen direction, which needs to be set, so that the phone screen is forced to be in a horizontal screen or vertical screen state.
The current version of Qt (Qt-4.6.2) does not provide an API to directly control the Symbian Phone screen mode, which needs to be done by using Symbian's API. The Set API function is: Caknappui::setorientationl (); The usage display code in QT is as follows:
#ifdef Q_os_symbian
void Mywidget::setportraitmode ()
{
Caknappui *aknappui = dynamic_cast<caknappui * > (Ceikonenv::static ()->appui ());
if (AKNAPPUI)
aknappui->setorientationl (caknappui::eappuiorientationportrait);
}
void Mywidget::setlandscapemode ()
{
Caknappui *aknappui = Dynamic_cast<caknappui *> (ceikonenv::static ()->appui ());
if (AKNAPPUI)
aknappui->setorientationl (Caknappui::eappuiorientationlandscape);
}
#endif
To use the Symbian function in the code above, we need to add several Symbian related header files to the source code.
#ifdef Q_os_symbian
#include <eikenv.h>
#include <coemain.h>
#include <aknappui.h >
#endif
and need to include the following in Qt's. Pro project file to ensure that the app compiles and links
Symbian {
LIBS + =-lconnmon-lcone-lavkon
}
Note: This feature cannot be simulated on the emulator, but it works correctly on Symbian phones.