Hi all,
I am new to QT, and for reference am using QT4.
I intend to draw points in an image of 255 x 255 in realtime.
To draw the points (number of points variable), I do:
p.setPen(b);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
...
p.drawPoint(y, x);
p.drawPoint(y, x);
QColor b(0,0,255,255);
QPainter p(&pixmap);
p.setPen(b);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
p.drawPoint(y, x);
...
p.drawPoint(y, x);
p.drawPoint(y, x);
To copy to clipboard, switch view to plain text mode
I am using a label to show the image where I just do
label->setPixmap(pixmap)
label->setPixmap(pixmap)
To copy to clipboard, switch view to plain text mode
Every 40ms I erase the image to restart drawing new image of points with:
p.eraseRect(0,0, 255, 255);
QPainter p(pixmap);
p.eraseRect(0,0, 255, 255);
To copy to clipboard, switch view to plain text mode
Everything is working fine, but...
First, I would like to know if this is the correct way of creating/showing image of points or if there is a better approach.
Second, this appears to be very CPU intensive, is there a problem with this code? Should I be using something different instead of QPainter and pixmap? I get up to 80% CPU usage on core2duo 2,53GHz. Thus unacceptable for such a simple program.
Third, intend to do this for maybe 3 or more images at the same time so not only is unacceptable but becomes impossible...
Thank you in advance for any help,
Regards
Bookmarks