相关疑难解决方法(0)

如何在QGraphicsView中启用平移和缩放

我正在使用python和Qt Designer来实现加载tiff图像并启用平移和缩放某些鼠标事件(滚轮缩放,按下滚轮 - 平移).

我正在研究一些可以处理图像等的选项和类,到目前为止我发现:

QGraphicsScene,QImage,QGraphicsView

我有三个班(只是测试)

  1. 具有QGraphicsView元素的ViewerDemo:

        """description of class"""
        # Form implementation generated from reading ui file 'GraphicsViewdemo.ui'
        try:
        _fromUtf8 = QtCore.QString.fromUtf8
        except AttributeError:
            def _fromUtf8(s):
                return s
            class Ui_Dialog(object):
                def setupUi(self, Dialog):
                    Dialog.setObjectName(("Dialog"))
                    Dialog.resize(500, 500)
                self.graphicsView = QtGui.QGraphicsView(Dialog)
                self.graphicsView.setGeometry(QtCore.QRect(0, 0, 500, 500))
                self.graphicsView.setObjectName(("graphicsView"))
                self.retranslateUi(Dialog)
                QtCore.QMetaObject.connectSlotsByName(Dialog)
            def retranslateUi(self, Dialog):
                Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None,
    QtGui.QApplication.UnicodeUTF8))
    
    Run Code Online (Sandbox Code Playgroud)
  2. MyForm类,即QDialog,我调用类ViewerDemo,加载Image,并将图像放入QGraphicsView

        import sys
        from ViewerDemo import *
        from PyQt4 import QtGui
        class MyForm(QtGui.QDialog):
            def __init__(self, …
    Run Code Online (Sandbox Code Playgroud)

python zoom pyqt4 qgraphicsview python-3.x

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

pyqt4 ×1

python ×1

python-3.x ×1

qgraphicsview ×1

zoom ×1