def __init__(self, engine=None, parent=None): super(DQuickView, self).__init__(engine, parent) self.setResizeMode(QtQuick.QQuickView.SizeViewToRootObject) self.engine().addImportPath(os.sep.join([get_parent_dir(__file__, 2), 'qml'])) if isWebengineUsed: # self.initWebengine() pass format = QSurfaceFormat() format.setAlphaBufferSize(8) format.setRenderableType(QSurfaceFormat.OpenGL) self.setFormat(format) self.setColor(QColor(Qt.transparent)) self.setClearBeforeRendering(True)
def createWindow(): view = QQuickView() view.setSurfaceType(QSurface.OpenGLSurface) fmt = QSurfaceFormat() fmt.setAlphaBufferSize(8) fmt.setRenderableType(QSurfaceFormat.OpenGL) view.setFormat(fmt) color = QColor() color.setRedF(0.0) color.setGreenF(0.0) color.setBlueF(0.0) color.setAlphaF(0.0) view.setColor(color) view.setClearBeforeRendering(True) view.setFlags(Qt.FramelessWindowHint | Qt.ToolTip | Qt.WindowStaysOnTopHint) context = view.rootContext() return (view, context)
#!/usr/bin/env python3 import sys # Check if we're in a virtual environment. if sys.prefix == sys.base_prefix: raise Exception('Not using a virtual environment! (See README.md)') from PyQt5.QtWidgets import QApplication from PyQt5.QtGui import QSurfaceFormat from widgets import * if __name__ == '__main__': qsf = QSurfaceFormat() qsf.setRenderableType(QSurfaceFormat.OpenGL) qsf.setProfile(QSurfaceFormat.CoreProfile) qsf.setVersion(4, 1) QSurfaceFormat.setDefaultFormat(qsf) app = QApplication(sys.argv) imp = IMPWindow() sys.exit(app.exec_())