PySide: Enabled QGraphicsView object doesn't take QMouseDoubleClickEvent



  • I have this simple program in qt. It creates 2 small squares with qgraphicsview. One square is "Enabled" at initialization so it is painted blue and the other square is Disabled so it is white at the initialization. When I double click on the disabled square QMouseDoubleClickEvent is called and the square is enabled(turned to blue). But when I double click on the Enabled(blue) square, the double click event doesn't work. How can I make the double click work on the blue(Enabled) square? Thank you

    import sys
    from PySide import QtGui
    from ui.Ui_MainWindow import Ui_MainWindow
    from PySide.QtGui import QApplication

    class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def init(self, parent=None):
    QtGui.QMainWindow.init(self)
    Ui_MainWindow.init(self)
    self.setupUi(self)
    self.graphicsView.setEnabled (False)
    self.graphicsView_2.setEnabled(True)

    def mouseDoubleClickEvent(self, event):
        self.graphicsView.setEnabled (True)
        self.graphicsView_2.setEnabled(True)
    

    def main():
    app = QApplication(sys.argv)
    wnd = MainWindow()
    wnd.show()
    sys.exit(app.exec_())

    if name == 'main':
    main()


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.