PDA

View Full Version : Painting multiple overlapping points with one QPainter



julesmules
5th December 2011, 16:43
Hey guys,

I'm fairly new to C++ and Qt and I have one question about using the QPainter module together with the QTimer. I am currently trying to paint points as part of a function plot. Each point is one part of the plot and as they are pretty close together i just want to paint one point at each timeout() signal. What I've got so far is only one point moving along the function path. How can I do it that the program paints all the points overlapping each other so I can see the path of the point? Do I have to create as many instances of points as I want to display?

Thanks in advance

Jules

mvuori
5th December 2011, 16:52
Apparently you are painting directly on some widget or paintdevice or whatever. You could instead paint on a bitmap and after each point blit that to your widget -- each time it will have one new point and all the old ones.

julesmules
5th December 2011, 17:07
Yes, I was painting on my main widget. So you say I should create a QPixmap and use the QPainter to paint on that and after each step tell the widget to display the pixmap? I think I'll manage to paint on a pixmap, but could you explain, how I can use that pixmap in the widget?