[Qt-qml] Problems rendering QML from within a QDeclarativeView

Bradley Smith bsmith at baysmith.com
Fri Jun 10 07:40:07 CEST 2011


The demo code is overly complex. Below is a simplified version which
solves several problems.

The transparency problem does not occur for me with the original code
or the code below. Perhaps it is an OpenGL driver problem?

  Bradley


#!/usr/bin/env python

import sys
from PySide.QtCore import QUrl
from PySide.QtGui import QGraphicsScene, QGraphicsView, QApplication,
QMessageBox
from PySide.QtDeclarative import QDeclarativeView
from PySide.QtOpenGL import QGLWidget

try:
    from OpenGL import GL
except ImportError:
    app = QApplication(sys.argv)
    QMessageBox.critical(None, "Drawer test",
                            "PyOpenGL must be installed to run this
example.",
                            QMessageBox.Ok | QMessageBox.Default,
                            QMessageBox.NoButton)
    sys.exit(1)


def main(argv):
    app = QApplication(argv)

    display_widget = QDeclarativeView()
    display_widget.setViewport(QGLWidget())
 
display_widget.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    display_widget.setSource(QUrl('drawer_demo.qml'))
    display_widget.show()
    display_widget.resize(640,480)

    sys.exit(app.exec_())

if __name__ == '__main__':
    main(sys.argv)


More information about the Qt-qml mailing list