下午好。QGraphicsItem上的toolTip大约在一秒钟后出现。可以更改此值吗?如果是这样的话,是怎么做的?
发布于 2020-06-14 05:51:54
也许您可以尝试使用
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);
}https://stackoverflow.com/questions/62364690
复制相似问题