[Qt-interest] QListWidget clicked() signal

Scott Aron Bloom Scott.Bloom at sabgroup.com
Sun Mar 8 14:23:10 CET 2009


The issue is your looking for a signal on an item click, and no item is
visible.

What you need to do, is on the view, overload the generic
mouseReleaseEvent and work from there...

Take a look at the QListView class to see how its implemented (it may be
in QAbstractItemView using "item for cursor" functions), but the net
result, somewhere there is code that is ignoring the click when the
cursor is not on an item.  

Scott

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Martin Fiala
Sent: Sunday, March 08, 2009 5:56 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QListWidget clicked() signal

Hello,
first, I'm new to this list, so hello everyone.
I've found many answers here before, but not to this one:

I'm using two QListWidget items in my form and want to add a signal to
each, that calls some function when the Widget is clicked. Sounds
pretty easy, but unfortunately, isn't. So far I was able to manage
with itemClicked signal, but the problem is, I need the signal to be
emitted even if the list is empty. itemClicked is emitted only if
there are items inside and clicked, so that will not work for me :(.
I searched a bit around and found out that QListWidget inherits
signals from QAbstractItemView... There exists a clicked (const
QModelIndex & index) slot but I've never managed to actually make it
work, so I'm not sure it is inherited. Anyone can help me with this?
I've tried clicked(), and clicked( My_listWidget..model()) and
clicked(My_listWidget.rootIndex()) but I get "No such signal.." for
all of them.. So I'm either supplying wrong QModelIndex or there is no
such signal for QListWidget. Either way, can someone advice me, how to
make a such a signal/functionality?

Thanks in advance for any info.
Martin Fiala
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list