I'm having some problem understanding how stuff is drawn on a widget with the QPainter.
If I do
{
int i;
for (i=0;i<10;i++)
{
painter.
drawLine(QLine(rand()%250,
rand()%100,
rand()%250,
rand()%100
));
}
}
void Render::paintEvent(QPaintEvent* event)
{
int i;
QPainter painter(this);
for (i=0;i<10;i++)
{
painter.drawLine(QLine(rand()%250,rand()%100,rand()%250,rand()%100));
}
}
To copy to clipboard, switch view to plain text mode
Where Render is a only derived from QWidget and it is put in a Layout to stretch it out and make it big. The code works fine.
I make new lines by clicking a button that calls a slot in Render class that then runs
update();
update();
To copy to clipboard, switch view to plain text mode
to generate a QPaintEvent
I get 10 new lines every time, is it possible to keep the old lines and just draw new lines on the old ones?
Bookmarks