下午好。大约一秒钟后,将出现QGraphicsItem上的toolTip。可以更改此值吗?如果是这样,如何?
可能您可以尝试使用
void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
您需要在事件处理代码中处理QEvent::ToolTip
。我从文档中删除了这段代码。在它下面。 (注意:我没有对此进行测试。)
//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);
}