3

私はPyQt4で遊んでいて、それが私の期待に応えていないことに気づきました。コードを検討してください

import sys
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QPalette, QGraphicsScene, QGraphicsProxyWidget, QGraphicsView, QPainter
from PyQt4.QtOpenGL import QGLWidget
from PyQt4.QtCore import QObject, pyqtSlot, QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView, QWebSettings
from batchq.pipelines.interpreters import PythonTerminal
from PyQt4 import QtCore, QtGui, QtWebKit
import PyQt4

class WithConsole(QtWebKit.QWebPage):
    def javaScriptConsoleMessage(self, msg, line, source):
        print '%s line %d: %s' % (source, line, msg)

if __name__ == '__main__':
    app = QApplication(sys.argv)

    webview = QWebView()
    webview.setAttribute(Qt.WA_X11NetWmWindowTypeDesktop)
    webview.setAttribute(Qt.WA_OpaquePaintEvent, True)
    settings=webview.settings()
    settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
    settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
    settings.setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True)
    settings.setAttribute(QWebSettings.LocalStorageEnabled, True)
    settings.setAttribute(QWebSettings.AutoLoadImages, True)

    page = WithConsole()
    webview.setPage(page)
    frame = webview.page().mainFrame()
    palette = webview.palette()
    palette.setBrush(QPalette.Base, Qt.transparent)
    webview.page().setPalette(palette)

    scene = QGraphicsScene()
    proxy = QGraphicsProxyWidget()
    proxy.setWidget(webview)
    rect = proxy.boundingRect()
    proxy.setPos(rect.width(), rect.height())
    proxy.show()
    scene.addItem(proxy)

    scene.setSceneRect(scene.itemsBoundingRect())
    view = QGraphicsView()
    view.setScene(scene)
    view.setViewport(QGLWidget())

    view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
    view.setCacheMode(QGraphicsView.CacheBackground)
    view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
    view.show()


    webview.setUrl(QUrl("http://bartaz.github.com/impress.js/#/bored"))
#    webview.setUrl(QUrl("http://gridster.net/"))
    view.show()
    app.exec_()

これは、トランジションなどでGLが有効になっている1つのページを表示する最小限のWebブラウザーを実装します。ただし、いくつかのWebページでテストすると、対話がChromeやSafariなどの他のブラウザーよりもはるかに遅れていることがすぐにわかります。特に、gridster.netでは、「グリッド」との相互作用が期待どおりに機能せず、impress.jsの場合、遷移はひどく遅くなります(GLがないとさらに遅くなります)。最後に、これはバインディングに依存しないようです。PySideでも遅いです。Qtはバージョン4.8.1です。

私の質問は、QtWebkitをgridster.jsと互換性を持たせることは可能ですか、そしてどのようにしてトランジションのパフォーマンスを向上させることができますか?

4

0 に答える 0