Line drawing using qpainter
-
After trying many things and failed, i finally came here to do what i was trying.
I want to display lines which are stored in a file named "line.txt" in comma seperated values.
i have successfully read the values, but unable to draw them on the screen.
please help. -
[quote author="QMartin" date="1360425719"]Hi!
You need to re-implement
@void paintEvent(QPaintEvent *);@
Inside it, create a QPainter. With it, call drawLine (look "here":https://qt-project.org/doc/qt-4.8/qpainter.html#drawLine). Hope this helps.
Regards[/quote]
i have tried it but somehow it is not working. It is working for a single line. but for drawing multiple lines it doesn't show them all.
-
[quote author="Thomas Zander" date="1360429277"]the method you likely want is the drawText().
Notice that you may just want to use a QTextDocument, which has a paint method too.
Or even higher level, use the QTextEdit widget.[/quote]
I need to draw only lines and not text.
anyway thanks for the help. -
Ok , i tried again and succeeded this time.
method used:
read all the lines from the file into a qvector<qline> and used qpainter::drawlines() to draw the lines all at a time.