I'm trying to create my own QGraphicsPixmapItem where I can active on hover mode and I want to paint a black border when I hover over the rect of the item, and go back to normal when I leave the rect space.
I started this code, but don't know what to do next. Also wanted to do a paintEvent, but QGraphicsPixmapItems doesn't have that. So am even more confused as don't think the paint method would be the same.
class PixmapItem(QGraphicsPixmapItem):
def __init__(self, pixmap, rect, parent=None):
super().__init__(parent)
self.pixmap = pixmap
self.setPixmap(self.pixmap)
self.rect = rect
self.setAcceptHoverEvents(True)
def hoverEnterEvent(self, *args, **kwargs):
pass
I could make the hover print 'hello' but can't do anything else, even with some examples, because those are with paintEvent and other type of items.
I would like to maintain the type of item if possible and paint the border as i said. But also don't know if it would be a better approach that's also simple.