diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 4f3a742..e492345 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -511,9 +511,16 @@ public:
 #if 0 // these values are reserved for Maemo5 - do not re-use them
         WA_Maemo5NonComposited = 126,
         WA_Maemo5StackedWindow = 127,
-        WA_Maemo5PortraitOrientation = 128,
-        WA_Maemo5LandscapeOrientation = 129,
-        WA_Maemo5AutoOrientation = 130,
+#endif
+
+        WA_LockPortraitOrientation = 128,
+        WA_LockLandscapeOrientation = 129,
+        WA_AutoOrientation = 130,
+
+#if 0 // these values are reserved for Maemo5 - do not re-use them
+        WA_Maemo5PortraitOrientation = WA_LockPortraitOrientation,
+        WA_Maemo5LandscapeOrientation = WA_LockLandscapeOrientation,
+        WA_Maemo5AutoOrientation = WA_AutoOrientation,
         WA_Maemo5ShowProgressIndicator = 131,
 #endif
 
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index fdb35d5..40697bf 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -141,6 +141,7 @@ public:
     int supportsPremultipliedAlpha : 1;
     int avkonComponentsSupportTransparency : 1;
     int menuBeingConstructed : 1;
+    int orientationSet : 1;
     QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
     static CEikButtonGroupContainer *cba;
 
@@ -295,6 +296,7 @@ inline QS60Data::QS60Data()
   supportsPremultipliedAlpha(0),
   avkonComponentsSupportTransparency(0),
   menuBeingConstructed(0),
+  orientationSet(0),
   s60ApplicationFactory(0)
 #ifdef Q_OS_SYMBIAN
   ,s60InstalledTrapHandler(0)
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 9a76b0a..e542a59 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -124,6 +124,10 @@
 #include "qtabwidget.h" // Needed in inTabWidget()
 #endif // QT_KEYPAD_NAVIGATION
 
+#ifdef Q_WS_S60
+#include <aknappui.h>
+#endif
+
 // widget/widget data creation count
 //#define QWIDGET_EXTRA_DEBUG
 //#define ALIEN_DEBUG
@@ -10810,6 +10814,42 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
             d->registerTouchWindow();
 #endif
         break;
+    case Qt::WA_LockPortraitOrientation:
+    case Qt::WA_LockLandscapeOrientation:
+    case Qt::WA_AutoOrientation: {
+        const Qt::WidgetAttribute orientations[3] = {
+            Qt::WA_LockPortraitOrientation,
+            Qt::WA_LockLandscapeOrientation,
+            Qt::WA_AutoOrientation
+        };
+
+        if (on) {
+            // We can only have one of these set at a time
+            for (int i = 0; i < 3; ++i) {
+                if (orientations[i] != attribute)
+                    setAttribute_internal(orientations[i], false, data, d);
+            }
+        }
+
+#ifdef Q_WS_S60
+        CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
+        const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
+            CAknAppUiBase::EAppUiOrientationPortrait,
+            CAknAppUiBase::EAppUiOrientationLandscape,
+            CAknAppUiBase::EAppUiOrientationAutomatic
+        };
+        CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
+        for (int i = 0; i < 3; ++i) {
+            if (testAttribute(orientations[i])) {
+                s60orientation = s60orientations[i];
+                break;
+            }
+        }
+        QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
+        S60->orientationSet = true;
+#endif
+        break;
+    }
     default:
         break;
     }
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 8e4e99a..094321b 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -328,6 +328,11 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
     bool desktop = (type == Qt::Desktop);
     //bool tool = (type == Qt::Tool || type == Qt::Drawer);
 
+#ifdef Q_WS_S60
+    if (!S60->orientationSet && QApplicationPrivate::app_compile_version >= QT_VERSION_CHECK(4, 7, 0))
+        q->setAttribute(Qt::WA_LockPortraitOrientation, true);
+#endif
+
     if (popup)
         flags |= Qt::WindowStaysOnTopHint; // a popup stays on top
 
