Bounding rect for lines
-
Hi all,
has Qt in QGraphicsScene an object which is able to keep track of a bounding rect, which only covers the objects' paths instead of the entire outline?
I want to have a tooltip over a path which contains three lines, but I want to have the bounding rect only over the tree lines, not over the entire rect they are creating.
The nearest solution would be for me currently to paint each line as a single object and put them in an own container to solve this problem. Do you have another solution for such a feature?
-
To illustrate it: I'm talking about something like this.
-
Solved it by overwriting the "shape" function and using within QPainterPathStroker and QPainterPath.
-
@Lachrymology
While you're waiting for someone who knows better than I:You'll never get "a bounding rect" for this, as what you want is not a rect! It's 3 rects. And there doesn't seem to be any single call somehow returning 3 rects in a list....
So I think either you set the tooltip for each separate line, or you go via https://doc.qt.io/archives/qt-4.8/qgraphicsscenehelpevent.html where you get the
QPoint
of the mouse and then calculate whether that intersects with each of your lines to decide whether to show the tooltip?EDIT Your latest post just crossed with mine, you may know better than I do!