Namespaces
Variants
Actions

Archived:Lock application orientation in Qt

Jump to: navigation, search
Archived.png
Archived: 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}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

This article shows how to lock the screen orientation of Qt apps in Qt 4.7.2 and later. Note that until Qt 4.7.1, on Symbian developers needed to use native code to lock screen orientation, as shown in Archived:Lock application orientation in Qt.

Article Metadata

Tested with
Compatibility
Platform(s): Qt 4.7.2 and later

Article
Created: olympio (03 Jun 2011)
Last edited: hamishwillee (11 Oct 2012)

Code

	void MainWindow::setOrientation()
{
 
Qt::WidgetAttribute attribute;
 
// for portrait
attribute = Qt::WA_LockPortraitOrientation;
 
// for landscape
attribute = Qt::WA_LockLandscapeOrientation;
 
 
setAttribute(attribute, true);
 
}

Where MainWindow inherits from QMainWindow. The function setAttribute belongs to QWidget.

This page was last modified on 11 October 2012, at 04:14.
186 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved