Painting on a QGraphicsScene without loosing the picture already on it. Qt C++ -
so question says, have qgraphicsview on ui. have made function puts image onto qgraphicsview:
// read new image file qimage image(":/images/myfile.png"); /// declare pointer scene qgraphicsscene *scene = new qgraphicsscene(); // add pixmap scene qimage 'image' scene->addpixmap(qpixmap::fromimage(image)); // set scene equal height , width of map image scene->setscenerect(0,0,image.width(),image.height()); // set scene graphicsview on ui ui->graphicsview->setscene(scene);
however want able paint dots @ specific x y values on image. have function quite nicely function called dots appear , picture vanishes :(. know because im setting scene again 1 dots on program gets rid of 1 thats using (the image one)
for(unsigned int = 0; < pixels.size(); i++) { x = pix_iter->second; y = pix_iter->first; scene->addellipse(x, y, 1, 1, pen, qbrush(qt::solidpattern)); pix_iter++; } ui->graphicsview->setscene(scene);
anyway dont know update scene add dots instead of setting new one
any appreciated.
in second snippet, re-create scene? why don't use ui->graphicsview->scene()
, add dots it?
Comments
Post a Comment