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()
    mWebView.setRenderHints(QPainter.SmoothPixmapTransform)

    settings

    mSettings = mWebView.settings()
    mSettings.setAttribute(QWebSettings.LocalStorageEnabled, True)
    mSettings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
    mSettings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True)
    mSettings.enablePersistentStorage(path=sys.path[0])

    load url and show

    mWebView.load(QUrl('http://www.nokia.com'))
    mWebView.show()

    enter the loop

    sys.exit(app.exec_())@

    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 com.nokia.meego 1.0

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

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

    url: 'http://www.nokia.com'
    }
    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.