[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    QListView braindamage
From:       Viktor Rosenfeld <rosenfel () informatik ! hu-berlin ! de>
Date:       2002-08-09 22:27:08
[Download RAW message or body]

Hi, 

I'm trying to enable/disable some buttons depending on the selection of
items in a listview.  It appears to me that QListView::selectedChanged()
would be the signal to do just that, but unfortunately, it does not get
emited, when the selected signal is deleted *, nor when the item becomes
unselected by clicking somewhere in the listview, where there is no
item.  I know, that the item becomes unselected, because selectedItem()
returns a null pointer.

Then there is currentChanged(), which is emited, when the current item
is deletet.  However, to disable the button, when no item is selected,
because the user clicked somewhere in the listview, I have to use
QListView::mouseButtonClicked, to check if he has clicked on an item or
not.

So right now, the code looks like this:

	connect(newNumbers, SIGNAL(selectionChanged(QListViewItem *)), 
		SLOT(toogleAdd(QListViewItem *)));
	connect(newNumbers, SIGNAL(currentChanged(QListViewItem *)), 
		SLOT(toogleAdd(QListViewItem *)));
	connect(newNumbers, 
		SIGNAL(mouseButtonClicked(int, QListViewItem *, const QPoint &, int)),
		SLOT(toogleAdd(int, QListViewItem *, const QPoint &, int)));

That's right, I have to connect to three signals and provide two slots
with differing signatures, which all do the same.  If I'm reading the
documentation right, then connecting to selectionChanged should be
sufficient.

I looked at some KDE apps, they all suffer from this problem.
Interestingly KAlarm gets it right, but it goes great length (custom
AlarmListView and AlarmListViewItem classes, that latter emit a signal
at deletion).

What am I missing here, or is this just a bug?

Thanks in advance, 
Viktor	
-- 
Viktor Rosenfeld
WWW: http://www.informatik.hu-berlin.de/~rosenfel/

[Attachment #3 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic