PDA

View Full Version : QGraphicsItem::setToolTip does not work



Nadia
4th September 2009, 14:31
Hi,

I have an item dierived from QGraphicsItem.

and I want a toolTips for this item



hotPoint::hotPoint(const QPointF& hotPoint)
{
setAcceptHoverEvents(true);
setToolTip("An important value");
point = hotPoint;
}


what else I should do to make toolTip shown?:)

wysota
5th September 2009, 08:55
You might want to call the base class implementation of the constructor. Apart from that you need to define boundingRect() properly and add the item to the scene.

Nadia
6th September 2009, 19:54
Hi,

Thanks for replay. I have added the item to scene and define boundingRect() properly:cool: but I found in docs that also need to set



setAttribute( Qt::WA_AlwaysShowToolTips)





Note that by default tooltips are only shown for widgets that are children of the active window. You can change this behavior by setting the attribute Qt::WA_AlwaysShowToolTips on the window, not on the widget with the tooltip.



I set this property to view and to main window cause I don't know who actually are active:p