Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.2
-
None
-
Arch Linux 64 bit
Description
Hello everyone, this is my first issue report - if something isn't up to standard please let me know!
I am currently trying to setup a QGraphicsView with hoverable quadratic curves.
For this purpose I subclassed `QGraphicsPathItem` and implemented the `hoverEnterEvent` and `hoverLeaveEvent` methods as follows (I'm aware this isn't the ideal way to achieve a colouring effect on hover):
void connection_graphics_item::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { QGraphicsItem::hoverEnterEvent(event); QPen pen; pen.setWidth(4.0f); pen.setColor(Qt::yellow); setPen(pen); }
void connection_graphics_item::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { QGraphicsItem::hoverLeaveEvent(event); QPen pen; pen.setWidth(4.0f); pen.setColor(Qt::black); setPen(pen); }
Doing this I noticed that the hover detection was off, from one side it would be fine, from the other side it would detect it far outside its visual bounds.
I looked a bit at the source of the `shape` function implementation and spotted this:
<https://code.woboq.org/qt5/qtbase/src/widgets/graphicsview/qgraphicsitem.cpp.html#881>
After reimplementing the function and using the same code - minus that last line, the hover detection for my quadratic curves worked flawless. I'm not sure if that last call can just be removed, as the function is used by other components as well, but it at least fixed it for `QGraphicsPathItem` for me.
Attachments
Issue Links
- relates to
-
QTBUG-80937 QGraphicsEllipseItem gives wrong shape when the span angle is below 360 degrees
- Reported