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

Correctly mapping QPointF coords to a QGraphicsScene



  • Hi,
    I am trying to implement a paint feature on a QGraphicsView for stylus pens. The scene can get zoomed and panned around, so I need to map event positions to the scene. The event parameter in QGraphicsView.tabletEvent() provides a posF() which is important for precision when drawing. But QGraphicsView's mapToScene() method only works for QPoints (aka it rounds QPointF) which results in a fuzzy line drawn with a pen instead of a precise clean one.
    Does someone know a convenient way to correctly map a QPointF position to the QGraphicsScene?
    Thank you!


  • Lifetime Qt Champion

    Hi,

    Taking a look at the method implementation, it looks like if would be simpler to add an overload to QGraphicsView for it.



  • Thanks! I am using Python though, not sure how to do it there/if that's even possible (how to get that Q_D d_func() method, sorry I'm really not into this)


  • Lifetime Qt Champion

    Sorry, I missed that you posted on the Qt for Python.

    These macro are used to grab the private class containing the implementation details of the public API. My suggestion implied that you would have had to rebuild Qt and in your case the bindings as well.

    One thing you can do is check the bug report system to see if there's something related. If not, you can open a feature request explaining your situation.


Log in to reply