如何将鼠标按下事件(QGraphicsScene)连接到小部件

时间:2018-10-05 09:13:48

标签: python pyqt4 qgraphicsscene

我需要将“鼠标按下事件”连接到功能。我在QGraphicsScene中编写了以下代码,如果我们单击Grid中的任何位置,它可能会打开一个小部件并显示3D图。

def mousePressEvent(self, evnt):
        print evnt
        print dir(evnt)
        print evnt.screenPos().x()
        print evnt.screenPos().y()


        self.ix = int(evnt.screenPos().x()/Setting.WIDTH)
        self.iy = int(evnt.screenPos().y()/Setting.HEIGHT)
        print self.ix , self.iy


        self.newwidget12 = QtGui.QWidget()
        # self.btn12 = QtGui.QPushButton()
        self.ix.clicked.connect(self.on_click_ripples)
        # self.newwidget12.mousePressEvent(self.on_clcik_ripples)
    # self.newwidget12.mousePressEvent(self.on_clcik_ripples)
        # self.ix.clicked.emit(self.on_clcik_ripples)
        self.scrollArea.setWidget(self.newwidget12)
    # class newwidget12(QtGui.QWidget)
    def on_click_ripples(self):


                    x,y = np.mgrid[-3:3:100j, -3:3:100j]

                    a = 0.3

                    a0 = 0.2

                    r1=np.sqrt((x-a)**2 + y**2)

                    values = np.sinc(-r1/a0)

                    mlab.surf(values, warp_scale='auto')

                    mlab.outline()

                    mlab.axes()
                    # mlab.test_contour3d()
                    mlab.show()

0 个答案:

没有答案