c++ - Custom Qt QGraphicsItem tooltip -


i'm looking ways implement simple custom tooltip qgraphicsitem.

i know can use settooltip set text tooltip. want change text dynamically when mouse hovers @ different parts of qgraphicsitem object.

what i'm thinking when event qevent::tooltip, change tooltip text in event handler. however, cannot find event function recieve qevent::tooltip qgraphicsitem.

or there ways handle event mouse hovers 2 seconds.

how can make it?

you implement hovermoveevent in derived qgraphicsitem class, , set tooltip based on position within graphics item

void myitem::hovermoveevent(qgraphicsscenehoverevent* event) {     qpointf p = event->pos();      // use p.x() , p.y() set tooltip accrdingly, example:     if (p.y() < height()/2)         settooltip("upper half");     else         settooltip("bottom half"); } 

notice have enable hover events item.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -