1 Attachment(s)
drawing lines using qpainter from file
I'm new to Qt programming and trying to build a gui program for a project. I need to draw multiple lines on the widget. The dimensions of the lines are stored in a file "line.txt". The file is correctly read by using qfile and qtextstream. I have also implemented the paintEvent() to draw one line. But when i'm trying to draw multiple lines, it shows no output. What's the problem and how to correct it? i'm attaching the code and the file "line.txt"
Re: drawing lines using qpainter from file
In future post, please post the relevant lines direct in the thread.
a) don't read the file every time paintEvent is called - which is quite often. Use the constructor and parse the file in a QList<QLine> or something similar.
b) Never call update or paint inside paintEvent!
Re: drawing lines using qpainter from file
There is this nice thing in Qt called QPicture, have a look at it.