[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: QListBox::highlighted() in extended-select mode
From: Adriaan de Groot <adridg () cs ! kun ! nl>
Date: 2003-02-01 23:58:36
[Download RAW message or body]
I'm having a little weirdness with highlighted() in QListBoxes in extended
select mode. It may just be a documentation issue. The list box starts off
with no item selected. If I select a single item in the list box,
highlighted(int) is emitted once. If I now select another single item in the
list, highlighted() is emitted _twice_, once for the item which was selected
and is no longer, and once for the new item that is selected. The attached
tiny program demonstrates this. I understand fully that I can use
isSelected() to discard the unwanted signal. The docs say:
The highlighted() signal is emitted when a new item gets highlighted, e.g.
because the user clicks on it or QListBox::setCurrentItem() is called.
To me, that suggests that it only gets called for the new item, not for the
old item. My question is: is this intentional? Should there be a note in the
docs saying "only d00fuses would use highlighted() in conjunction with
extended selection"?
--
pub 1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <groot@kde.org>
Key fingerprint = 934E 31AA 80A7 723F 54F9 50ED 76AC EE01 FEA2 A3FE
["t.cpp" (text/x-c++src)]
#include <qapplication.h>
#include <qstring.h>
#include "t.moc"
#include <iostream>
MyWindow::MyWindow(QWidget *parent) :
QVBox(parent)
{
qc = new QListBox(this);
qc->setSelectionMode(QListBox::Extended);
ql = new QLabel(this);
tally = 0;
boxHighlighted(0);
for (int i=0; i<6; i++)
{
qc->insertItem(QString::fromLatin1("Item %1").arg(i));
}
QObject::connect(qc,SIGNAL(highlighted(int)),
this,SLOT(boxHighlighted(int)));
}
void MyWindow::boxHighlighted(int i)
{
QString s;
tally+=i;
s = QString::fromLatin1("Tally = %1").arg(tally);
cerr << s << endl;
ql->setText(s);
}
int main(int argc,char **argv)
{
QApplication a(argc,argv);
MyWindow w(0L);
a.setMainWidget(&w);
w.show();
return a.exec();
}
["t.h" (text/x-chdr)]
#include <qlistbox.h>
#include <qvbox.h>
#include <qlabel.h>
class MyWindow : public QVBox
{
Q_OBJECT
public:
MyWindow(QWidget *parent);
public slots:
void boxHighlighted(int);
protected:
QListBox *qc;
QLabel *ql;
int tally;
} ;
>> 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