Python PyQt5.QtWidgets 模块,QOpenGLWidget() 实例源码
我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用PyQt5.QtWidgets.QOpenGLWidget()。
def __init__(self, mainWindow):
super().__init__()
self.mainWindow = mainWindow
viewport = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers))
viewport.format().setSwapInterval(0) #disable VSync.
viewport.setAutoFillBackground(False)
viewport = QtWidgets.QOpenGLWidget()
viewportFormat = QtGui.QSurfaceFormat()
viewportFormat.setSwapInterval(0) #disable VSync
viewportFormat.setSamples(2**8)
viewportFormat.setDefaultFormat(viewportFormat)
viewport.setFormat(viewportFormat)
self.setViewport(viewport)
self.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
#self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
self.setDragMode(QtWidgets.QGraphicsView.NoDrag)
self.scoreScene = GuiScore(self)
self.setScene(self.scoreScene)
api.getCallbacksDatabase().setCursor.append(self.centerOnCursor) #returns a dict
api.getCallbacksDatabase().updateBlockTrack.append(self.updateMode)
self.xFactor = 1 #keep track of the x stretch factor.
style = """
QScrollBar:horizontal {
border: 1px solid black;
}
QScrollBar::handle:horizontal {
background: #00b2b2;
}
QScrollBar:vertical {
border: 1px solid black;
}
QScrollBar::handle:vertical {
background: #00b2b2;
}
"""
self.setStyleSheet(style)
self._zoom() #no parameters, uses config values