Re: How to delay a Signal?
I don't think there is such an option for delay in connect(), but you could simply use a QTimer with 2 seconds inside your slot.
Re: How to delay a Signal?
Thanks for answering,
but this isn`t the right solution. I wont only a signal, if the mousepointer was 2-3 seconds over the table. With your idea, the signal is 2-3 seconds later on my slot, also if the mouse was only 1 second over the table.
Re: How to delay a Signal?
Ok, I've misunderstand you. In your case you have to subclass and use QWidget::enterEvent() and QWidget::leaveEvent() (in conjunction with a QTimer) to prove if the cursor was 3 sec over the widget and then send your own signal.
Re: How to delay a Signal?
what you could do is using QTimer like
Code:
connect(timer, SIGNAL(timeout()), this, SLOT(setT()));
timer->start(1000);
void setT()
{
xxxx->blockSignals(true);
}
Re: How to delay a Signal?
Since I hate my work right now and the van Damme movie, I currently watch, sucks, I am gentile and post the code I was thinking of...
Code:
/// local timer t.
XX::XX()
{
t.setSingleShot(true);
connect(&t, SIGNAL(timeout()), this, SLOT(timerslot()));
}
XX::timerslot()
{
// if you want do so something right here, if not, you could
// direct emit the signal in the connect statement.
emit mouseFor3SecondsOverWidget();
}
XX::enterEvent()
{
t.start(3000);
}
XX::enterLeave()
{
t.stop();
}
Re: How to delay a Signal?