×
Namespaces

Variants
Actions

Archived:Lock application orientation in Qt

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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 withCompatibility
Platform(s): Qt 4.7.2 and later
Symbian
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 01:14.
49 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×