Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Question about QPainterPathStroker::createStroke()



  • I am "abusing" this function to create a polygon used for testing whether the user has moved the mouse or clicked inside of it. The idea is to provide tooltips and/or additional information about an edge in a GraphViz graph. Since GraphViz gives you a list of control points (B-splines) for each edge, I use the tinyspline library to re-calculate some of the points along the edge, create a QPainterPath from that, and then stroke it with width = 8 using the above function. Then I call the QPainterPath::toFillPolygon() function and add the polygon it returns to a "hit list", so to speak, (a member variable in my widget class) which is queried in the appropriate mouse event functions. The QPainterPath object itself is never used, except to get the polygon.

    However, my question is this:
    According to the documentation, it says: "The generated path should only be used for outlining the given painter path. Otherwise it may cause unexpected behavior." This seems rather strange to me because the stroked path is returned as an object, not a pointer or reference. I haven't noticed any strange behavior yet, but I do believe that one should take such warnings seriously.

    Am I in danger of undefined behavior here?



  • it's just a container of information for drawing graphics primitives. If all you are doing with it is generating a polygon then I'd gamble on being OK.


Log in to reply