Mouseover in Graphics View Framework



  • Hello,
    I'd like to have an image in the scene that is visible when the mouse pointer is inside its area and invisible otherwise.

    I tried to put the image in a QGraphicsPixmapItem and setOpacity(0.0), but the item doesn't receive hoverEnterEvents any more after that (it does receive them if I set the opacity to some other value like 0.01).

    What defines the area for mouseover events in items? If it was defined by shape() I could reimplement it, but it doesn't seem the case.
    Can something invisible get hoverEnterEvents?

    Also an item doesn't get an hoverEnterEvent() on show() when the pointer is over it (conversely a QLabel (outside of the scene) get an enterEvent() on show() when the pointer is over it).
    Is there a way to make it happen except checking isUnderMouse() and emulating the hoverEnterEvent() every time I show() it?

    Thanks,
    Nando



  • you can manually create and send events using "sendEvent()":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#sendEvent or "postEvent()":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#postEvent

    alternatively, you could reimplement said events on your view and manually check whether the mouse has entered one of your invisible items, since afaik any item that is set to invisible won't receive any events.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.