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

QGraphicsScene and QGraphicsLineItem Problem



  • Hey Everyone,

    I've followed the Tutorial (link below) of QGraphicsScene and everything works fine.
    http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html

    Now I've drawn several lines on the scene. When I select one of them, how can I trace back the draw information. I mean the positions of two points. What I wanna do is, when I select the line, I can change its orientation or length with mouse click.

    Thanks in advance
    Best Regards



  • First, when the item is selected, you can use
    qgraphicsitem_cast<QGraphicsLineItem*>(pItem)
    to determine it's actually a line item. With that line item, you can now access and modify the line() property.


Log in to reply