我在QgraphicsView的Move事件里面写了Tooltip,目的是实时显示坐标。
我的代码是:
void RoboGraphicsView::mouseMoveEvent(QMouseEvent *event)
{
//测量尺
if(CanMeasure)
{
QString pStr("x=%1,y=%2");
pStr = pStr.arg(event->pos().x()).arg(event->pos().y());
QToolTip::showText(mapToGlobal(event->pos()), pStr);
}
那个QtoolTip就闪了1下就消失了,然后我看了一下Qt文档说明,把代码改成这样。
QToolTip::showText(mapToGlobal(event->pos()), pStr,this,this->rect(),5000);
还是老样子,然后我又。
this->setAttribute(Qt::WA_AlwaysShowToolTips);
this->setToolTipDuration(5000);
这个Tooltip还是老样子,我服了,而且还有一个奇怪的现象,这个Qtooltip在我移动的很快的时候会显示一个大黑框。
请各位大神指点指点,我实在没招了。
。。。没币了,可以加我Q838771417,有偿。