static const int DELAY = 200; // ms
...
connect(lineEdit,
SIGNAL(textChanged
(QString)),
this,delayChange
()));
connect(this,
SIGNAL(textChangeDelayed
(QString)),proxyModel,
SLOT(setFilterFixedString
(QString)));
....
void delayChange()
{
delay.start();
QTimer::singleShot(DELAY,
this,
SLOT(informChange
()));
}
void informChange()
{
if (delay.elapsed() >= DELAY)
emit textChangeDelayed(lineEdit->text());
else
QTimer::singleShot(DELAY
- delay.
elapsed(),
this,
SLOT(informChange
()));
}
QTime delay;
static const int DELAY = 200; // ms
...
connect(lineEdit,SIGNAL(textChanged(QString)),this,delayChange()));
connect(this,SIGNAL(textChangeDelayed(QString)),proxyModel,SLOT(setFilterFixedString(QString)));
....
void delayChange()
{
delay.start();
QTimer::singleShot(DELAY, this, SLOT(informChange()));
}
void informChange()
{
if (delay.elapsed() >= DELAY)
emit textChangeDelayed(lineEdit->text());
else
QTimer::singleShot(DELAY - delay.elapsed(), this, SLOT(informChange()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks