Important: Please read the Qt Code of Conduct -

Enable auto-rotation in QWebView

  • Perhaps it has been answered before, but I have tried a simple WebView PySide sample:

    @import sys

    from PySide.QtCore import *
    from PySide.QtGui import *
    from PySide.QtWebKit import *
    from PySide.QtOpenGL import *

    create Qt app

    app = QApplication(sys.argv)

    create webview

    mWebView = QWebView()


    mSettings = mWebView.settings()
    mSettings.setAttribute(QWebSettings.LocalStorageEnabled, True)
    mSettings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
    mSettings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True)

    load url and show


    enter the loop


    But, when I try it on a N9x0 device, it doesn't rotate... I supose that it needs to use qt-mobility pack, but... how to enabling auto-rotation?

    Thank you very much and best regards

  • I have changed to qml instead of pure python gui definition. Now I use this qml file, and it seems to work as expected:
    @import QtQuick 1.0
    import QtWebKit 1.0
    import 1.0

    Window {
    id: rootWindow
    WebView {
    id: webView
    anchors.fill: parent

    settings.javascriptEnabled: true
    settings.localStorageDatabaseEnabled: true
    settings.offlineStorageDatabaseEnabled: true
    settings.offlineWebApplicationCacheEnabled: true

    url: ''

Log in to reply