[PyQt] QGraphicsView item select

Alfredo Junior junixrj at yahoo.com
Wed Apr 11 04:05:19 BST 2012


Thank you for your help.

But I can't make something like that.

In my example only tableWidget works:

class Init(QtGui.QMainWindow):
    def __init__(self):
        super(Init, self).__init__()
        self.initUI()
    def initUI(self):
        uic.loadUi(os.path.join(os.getcwd(), "ui/window.ui"), self)
        self.scene = QtGui.QGraphicsScene()
        pixItem = QtGui.QPixmap("picture.png")
        self.scene.addItem(pixItem)

        self.graphicsView.setScene(self.scene)
        # my problem [begin]
self.scene.selectionChanged.connect(self.gameSelected)
        # my problem [end]
        self.tableWidget.selectionModel().selectionChanged.connect(self.gameSelected)
    def gameSelected(self):
        print "Selection changed"

The scene.selectionChanged doesn't work.

Some tip?

----- Original Message -----
From: Andreas Pakulat <apaku at gmx.de>
To: pyqt at riverbankcomputing.com
Cc: 
Sent: Saturday, April 7, 2012 7:05 AM
Subject: Re: [PyQt] QGraphicsView item select

On 06.04.12 11:32:34, Alfredo Junior wrote:
> Hi people, 
> 
> I am writing a PyQt application.
> There is a sqlite database where I store data collected from the mame games(mamedev.org).
> I created a QGraphicsView with the screens of the games.
> Also created a QTableWidget with information about the games.
> Now, I need these items to be selectable (simultaneously).
> The moment I select a game in QTableWidget, it must be selected in QGraphicsView (if it exists) and vice versa.
> I have no idea how can I do this.

Listen to the corresponding selecion-changed signals of the views and
then update the selection on the corrwpspndig "other" one.

Andreas

_______________________________________________
PyQt mailing list    PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt



More information about the PyQt mailing list