class OverlayWidget(QtGui.QWidget): def __init__(self, *args): super(OverlayWidget, self).__init__(*args) # Set this widget itself to be transparent self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # We need to set the base colour of the qml widget to be transparent. # This is done by setting its palette. palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Base, QtCore.Qt.transparent) self.setPalette(palette) self.qml_view = QDeclarativeView(self) self.qml_view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.qml_view.setPalette(palette) self.qml_view.setResizeMode(QDeclarativeView.SizeRootObjectToView) url = QUrl('dynamic_drawers.qml') self.qml_view.setSource(url) def resizeEvent(self, event): self.qml_view.resize(event.size())
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_())
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_())
def create(self, mimeType, url, argumentNames, argumentValues): if mimeType != 'application/x-qml': return None for name, value in zip(argumentNames, argumentValues): if name == 'width': width = int(value) elif name == 'height': height = int(value) view = QDeclarativeView() view.resize(width, height) view.setSource(url) return view
class OverlayWidget(QtGui.QWidget): def __init__(self, *args): super(OverlayWidget, self).__init__(*args) # Set this widget itself to be transparent self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # We need to set the base colour of the qml widget to be transparent. # This is done by setting its palette. palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Base, QtCore.Qt.transparent) self.setPalette(palette) self.qml_view = QDeclarativeView(self) self.qml_view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.qml_view.setPalette(palette) url = QUrl('drawer_demo.qml') self.qml_view.setSource(url) def resizeEvent(self, event): self.qml_view.resize(event.size())