How can I reimplement hoverMoveEvent for different QGraphicsItem classes without copy/pasting code for each class
-
I agree this may be more a c++ question than a Qt question and i'm sorry.
Here is my problem, I want to subclass and reimplement a protected method for QGraphicsEllipseItem, QGraphicsPathItem, QGraphicsPolygonItem, QGraphicsRectItem, etc.
Is there another solution than subclassing each of them one by one? -
Hi,
Depending on what you want to do, maybe an event filter could be simpler ?
-
Thanks for your answer, I want to implement some tooltip on mouse hover. So idealy I would also need a few setters, not just the event reimplementation.
-
Might be a silly question but why not use setToolTip ?
-
Hum, that's not silly at all.
Well ... at first I didn't know it was so easy, so I went the reimplement way, and now I have some features I can't have just by using setToolTip -
What features ?
-
Sorry for the late answer, I was sick.
Main features are reimplementing shape() and mouse enter/leave events -
@JulienMaille
Hi
Mouse enter/leave can be handled by a event filter but
https://doc.qt.io/qt-5/qgraphicsellipseitem.html#shape
is a virtual function and it can only be handled in the class by override as its not seen by
an event filter.Hope you are better now then :)