本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView.verticalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.verticalScrollBar方法的具体用法?Python QGraphicsView.verticalScrollBar怎么用?Python QGraphicsView.verticalScrollBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.verticalScrollBar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CarlaPatchbayW
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import verticalScrollBar [as 别名]
class CarlaPatchbayW(QFrame, PluginEditParentMeta, HostWidgetMeta):
#class CarlaPatchbayW(QFrame, PluginEditParentMeta, HostWidgetMeta, metaclass=PyQtMetaClass):
def __init__(self, parent, host, doSetup = True, onlyPatchbay = True, is3D = False):
QFrame.__init__(self, parent)
self.host = host
if False:
# kdevelop likes this :)
host = CarlaHostMeta()
self.host = host
# -------------------------------------------------------------
self.fLayout = QGridLayout(self)
self.fLayout.setContentsMargins(0, 0, 0, 0)
self.fLayout.setSpacing(1)
self.setLayout(self.fLayout)
self.fView = QGraphicsView(self)
self.fKeys = PixmapKeyboardHArea(self)
self.fPeaksIn = DigitalPeakMeter(self)
self.fPeaksOut = DigitalPeakMeter(self)
self.fPeaksCleared = True
self.fPeaksIn.setColor(DigitalPeakMeter.BLUE)
self.fPeaksIn.setChannels(2)
self.fPeaksIn.setOrientation(DigitalPeakMeter.VERTICAL)
self.fPeaksIn.setFixedWidth(25)
self.fPeaksOut.setColor(DigitalPeakMeter.GREEN)
self.fPeaksOut.setChannels(2)
self.fPeaksOut.setOrientation(DigitalPeakMeter.VERTICAL)
self.fPeaksOut.setFixedWidth(25)
self.fLayout.addWidget(self.fPeaksIn, 0, 0)
self.fLayout.addWidget(self.fView, 0, 1) # self.fViewWidget if is3D else
self.fLayout.addWidget(self.fPeaksOut, 0, 2)
self.fLayout.addWidget(self.fKeys, 1, 0, 1, 0)
# -------------------------------------------------------------
# Internal stuff
self.fParent = parent
self.fPluginCount = 0
self.fPluginList = []
self.fExternalPatchbay = False
self.fIsOnlyPatchbay = onlyPatchbay
self.fSelectedPlugins = []
self.fCanvasWidth = 0
self.fCanvasHeight = 0
# -------------------------------------------------------------
# Set-up Canvas Preview
self.fMiniCanvasPreview = self.fParent.ui.miniCanvasPreview
self.fMiniCanvasPreview.setRealParent(self)
self.fMovingViaMiniCanvas = False
# -------------------------------------------------------------
# Set-up Canvas
self.scene = patchcanvas.PatchScene(self, self.fView)
self.fView.setScene(self.scene)
self.fView.setRenderHint(QPainter.Antialiasing, bool(parent.fSavedSettings[CARLA_KEY_CANVAS_ANTIALIASING] == patchcanvas.ANTIALIASING_FULL))
if parent.fSavedSettings[CARLA_KEY_CANVAS_USE_OPENGL] and hasGL: # and not is3D:
self.fViewWidget = QGLWidget(self)
self.fView.setViewport(self.fViewWidget)
self.fView.setRenderHint(QPainter.HighQualityAntialiasing, parent.fSavedSettings[CARLA_KEY_CANVAS_HQ_ANTIALIASING])
self.setupCanvas()
QTimer.singleShot(100, self.slot_restoreScrollbarValues)
# -------------------------------------------------------------
# Connect actions to functions
parent.ui.act_settings_show_meters.toggled.connect(self.slot_showCanvasMeters)
parent.ui.act_settings_show_keyboard.toggled.connect(self.slot_showCanvasKeyboard)
self.fView.horizontalScrollBar().valueChanged.connect(self.slot_horizontalScrollBarChanged)
self.fView.verticalScrollBar().valueChanged.connect(self.slot_verticalScrollBarChanged)
self.scene.scaleChanged.connect(self.slot_canvasScaleChanged)
self.scene.sceneGroupMoved.connect(self.slot_canvasItemMoved)
self.scene.pluginSelected.connect(self.slot_canvasPluginSelected)
self.fMiniCanvasPreview.miniCanvasMoved.connect(self.slot_miniCanvasMoved)
self.fKeys.keyboard.noteOn.connect(self.slot_noteOn)
self.fKeys.keyboard.noteOff.connect(self.slot_noteOff)
# -------------------------------------------------------------
# Load Settings
settings = QSettings()
#.........这里部分代码省略.........
示例2: View
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import verticalScrollBar [as 别名]
class View(QWidget):
trigger_focus_event = QtCore.pyqtSignal(str)
def __init__(self, emacs_xid, buffer, view_info):
super(View, self).__init__()
self.buffer = buffer
self.emacs_xid = emacs_xid
# Init widget attributes.
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_X11DoNotAcceptFocus, True)
self.setContentsMargins(0, 0, 0, 0)
self.installEventFilter(self)
# Init attributes.
self.view_info = view_info
(self.buffer_id, self.x, self.y, self.width, self.height) = view_info.split(":")
self.x = int(self.x)
self.y = int(self.y)
self.width = int(self.width)
self.height = int(self.height)
# Build QGraphicsView.
self.layout = QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
self.graphics_view = QGraphicsView(buffer, self)
self.graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing)
# Remove damn border from QGraphicsView.
self.graphics_view.setFrameStyle(0)
self.graphics_view.setStyleSheet("QGraphicsView {background: transparent; border: 3px; outline: none;}")
self.layout.addWidget(self.graphics_view)
# NOTE: show function must start before resize to trigger *first* resizeEvent after show.
self.show()
# Resize after show to trigger fit view operation.
self.resize(self.width, self.height)
def resizeEvent(self, event):
# Fit content to view rect just when buffer fit_to_view option is enable.
if self.buffer.fit_to_view:
if event.oldSize().isValid():
self.graphics_view.fitInView(self.graphics_view.scene().sceneRect(), Qt.KeepAspectRatio)
QWidget.resizeEvent(self, event)
def eventFilter(self, obj, event):
# Focus emacs buffer when user click view.
if event.type() in [QEvent.MouseButtonPress, QEvent.MouseButtonRelease,
QEvent.MouseMove, QEvent.MouseButtonDblClick, QEvent.Wheel]:
# Send mouse event to applicatin view.
self.trigger_focus_event.emit("{0},{1}".format(event.globalX(), event.globalY()))
# Stop mouse event.
return True
return False
def showEvent(self, event):
# NOTE: we must reparent after widget show, otherwise reparent operation maybe failed.
self.reparent()
# Make graphics view at left-top corner after show.
self.graphics_view.verticalScrollBar().setValue(0)
self.graphics_view.horizontalScrollBar().setValue(0)
def reparent(self):
xlib_display = get_xlib_display()
view_xid = self.winId().__int__()
view_xwindow = xlib_display.create_resource_object("window", view_xid)
emacs_xwindow = xlib_display.create_resource_object("window", self.emacs_xid)
view_xwindow.reparent(emacs_xwindow, self.x, self.y)
xlib_display.sync()
def handle_destroy(self):
self.destroy()