Reputation: 35
Good afternoon. The toolTip on QGraphicsItem appears after about one second. Can this value be changed? If so, how?
Upvotes: 1
Views: 327
Reputation: 12831
Probably you can give a try using
void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
You need to handle the QEvent::ToolTip
in your event handling code. I lifted that piece of code from documentation. And below it is. (Note: I did not test this.)
//CREATE AN EMPTY RECT
QRect rect();
//HANDLE THE QEvent::ToolTip
if (event->type() == QEvent::ToolTip) {
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
int index = itemAt(helpEvent->pos());
if (index != -1) {
//HERE YOU CAN CONTROL TIME.
QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip(), nullptr,rect,<<TIME YOU WANT TO SET>>);
} else {
QToolTip::hideText();
event->ignore();
}
return true;
}
return QWidget::event(event);
}
Upvotes: 1