Draw a line in Scene (not adding)
-
Hi everyone.
First of all thanks a lot for helping me and reading this post.I woudl like to draw a line in a Scene or Qgraphicsview.
i got that adding the line to the Scene but I do not want to adding I would like to draw the line using "void QPainter::drawLine(const QLineF & line)" with the same coordinates than in the scene.Is it possible to do that??
thanks a lot!!!
-
Hi
well you can draw the line with mouse
http://www.walletfox.com/course/qgraphicsitemruntimedrawing.php -
@AlvaroS said:
QMap so I would like to use paintEvent to draw the lines from QMap without adding to scene.
No, you cannot draw something to scene that is not inserted. at least in any good way.
You can however, make your own item, insert that into scene,
override paintEvent and draw lines there, but that will be inside the area of the Item, not whole scene.U can then make the custom item very big, but it will be come silly.
So why do u want to have lines, but not really want to have lines ?
something is strange here ? :) -
@mrjj I have lines and I have head arrows. For each line there is a head arrow. When user remove a line the head arrow is still there so i would like to remove head arrow as well when user remove a line. This happens because I add the head arrows in the scene so i thought that a good idea to solve this is not adding head arrow to the scene, just draw it.
-
@AlvaroS
ok. seems a bit messy.
Do you really need a QGraphicsScene then ?
You could also draw it as a custom control. you need zooming etc ?In any case, did u see this example
http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.htmlit even has arrowhead class :)