Qt-interest Archive, April 2007
Tooltips on QGraphicsItems
Message 1 in thread
Hi,
Is there an easy way to display a tooltip for a QGraphicsItem only when
the user hovers over the actual painted pixels, but not on the
transparent areas? It seems that creating a QGraphicsRectItem with an
outline only, provides a tooltip even inside the unpainted region.
I could do it with a custom hover events handler, but I wonder if there
is some qpainter associated parameter that affects this or another way I
am not aware of.
thanks in advance,
--stathis
--
[ signature omitted ]
Message 2 in thread
Hi Stathis,
Stathis schrieb:
> Hi,
>
> Is there an easy way to display a tooltip for a QGraphicsItem only
> when the user hovers over the actual painted pixels, but not on the
> transparent areas? It seems that creating a QGraphicsRectItem with an
> outline only, provides a tooltip even inside the unpainted region.
>
> I could do it with a custom hover events handler, but I wonder if
> there is some qpainter associated parameter that affects this or
> another way I am not aware of.
did you also try to overwrite shape() to return the correct outline
instead of boundingRect()?
http://doc.trolltech.com/4.2/qgraphicsitem.html#shape
This is in other cases used to have finer control when an item is hit,
so why not here? I think it's worth a try...
Good Luck,
Daniel
>
> thanks in advance,
> --stathis
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 3 in thread
Daniel Walz wrote:
> Hi Stathis,
>
> Stathis schrieb:
>> Hi,
>>
>> Is there an easy way to display a tooltip for a QGraphicsItem only
>> when the user hovers over the actual painted pixels, but not on the
>> transparent areas? It seems that creating a QGraphicsRectItem with an
>> outline only, provides a tooltip even inside the unpainted region.
>>
>> I could do it with a custom hover events handler, but I wonder if
>> there is some qpainter associated parameter that affects this or
>> another way I am not aware of.
> did you also try to overwrite shape() to return the correct outline
> instead of boundingRect()?
> http://doc.trolltech.com/4.2/qgraphicsitem.html#shape
> This is in other cases used to have finer control when an item is hit,
> so why not here? I think it's worth a try...
>
> Good Luck,
> Daniel
>>
>> thanks in advance,
>> --stathis
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>
>
Hi Daniel,
Thanks for replying, this was a good hint! For anyone who may look back
to the thread for a solution, here is how I made only the outline of my
rectangle trigger the tooltip:
QPainterPath shape() const
{
// This will defines the shape of the item
// In this case a simple rectangle
QPainterPath shapePath;
shapePath.addRect( boundingItem->rect() );
// This will create and return a new path by outlining
// the shape of the item defined before.
QPainterPathStroker outlinePath;
outlinePath.setWidth( thickness );
return outlinePath.createStroke ( shapePath );
}
Thanks again.
regards,
stathis
--
[ signature omitted ]