[PyQt] Hover Event for a QGraphicsItem

sw33tz nyavuz.nm20 at gmail.com
Sat May 7 18:46:28 BST 2016


I want some small text to pop up when I have my curser over a QGraphicsItem
in my QGraphicsScene. I have a class that inherits from QGraphicsItem, and
this represents my graphical items in the scene.

I tried using the QGraphicsItem.hoverEnterEvent and I also set the
setAcceptHoverEvents(True), but I still can't enable that hover event. I
also came across an event filter method but I'm not sure where to implement
it.

Should I install the event filter in the QGraphicsItem class, or the scene?
I tried both and I'm still not getting the desired result. I want to be able
to hover over all the items in the scene.


class HoverEventFilter(QtCore.QObject):
    def eventFilter(self, receiver, event):
        if (event.type() == QtCore.QEvent.HoverEnter):
            # this is for test purposes
            print 'hover event'
            return True
        else:
            # Call Base Class Method to Continue Normal Event Processing
            return super(HoverEventFilter, self).eventFilter(receiver,
event)



--
View this message in context: http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283.html
Sent from the PyQt mailing list archive at Nabble.com.


More information about the PyQt mailing list