[PyQt] qlistview

Baz Walter bazwal at ftml.net
Thu Oct 30 22:42:12 GMT 2008


kachim kachim wrote:
> hi,
> I'm quite newbie in pyqt, so maybe my question is silly but I couldn't
> find answer with google helps. I want to know when the user clicks on
> my listview. Now I'm using void clicked (const QModelIndex&) signal
> but it isn't what I want, signal is emitted only when then index is
> valid. It is also interesting for me when index is invalid. How can I
> do this?

class ListView(QListView):
     def __init__(self, parent):
         QListView.__init__(self, parent)

     def mousePressEvent(self, event):
         if not self.indexAt(event.pos()).isValid():
             print 'invalid index'
         QListView.mousePressEvent(self, event)


Regards
Baz Walter


More information about the PyQt mailing list