I am trying to visualize a calculation by drawing ellipses with QPainter.drawEllipse. Initially all ellipses have the same color but after the calculations the ellipses should have different colors according to the result. But the color never changes, below is an example of code:
void CoordPlot:: paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.setWindow(-800000,-100000,900000,900000);
painter.scale(1.0,1.0);
painter.rotate(90.0);
QColor c1(255,0,0,255);
QBrush b1(c1);
painter.setBrush(b1);
//just a test to draw an ellipse and a rectangle, works fine
painter.drawEllipse(x,y,5000,5000);
painter.drawRect(a,b,5000,5000);
//plot the dataset, does not work ok, the color is never changed!
int s=0;
for(unsigned int i=0; i<dataset.size(); i++){
//Set the RGB alpha value to c1 from the dataset
c1.setRgb(dataset[i].r,dataset[i].g,dataset[i].b,255);
painter.setBrush(b1);
painter.drawEllipse(dataset[i].y,dataset[i].x,6000,6000);
}
}
Pseudo code:
calculate and update RGB values in the dataset[]
repaint();
the colors are not changing...
Any hint?
Regards
Pete
Bookmarks