Hi there,

I would like to create a image (on the fly), fill it with colors and then display it using a QGraphicsScene. I managed to write the code but the pixels that I made blue are not visible. Any ideas on what is wrong?

* part of the view class (the main code regarding the question is in the initializeScene function):

Qt Code:
  1. cGeometryViewer::cGeometryViewer(QWidget *parent) :
  2. QGraphicsView(parent)
  3. {
  4. m_scene = new QGraphicsScene(0, 0, MATRIXWIDTH, MATRIXHEIGHT);
  5. setScene(m_scene);
  6. }
  7.  
  8. void cGeometryViewer::setGeometry(cGeometry *geometry)
  9. {
  10. m_geometry = geometry;
  11. initializeScene();
  12. }
  13.  
  14. void cGeometryViewer::initializeScene()
  15. {
  16. QImage img(MATRIXWIDTH, MATRIXHEIGHT,QImage::Format_ARGB32);
  17.  
  18. //just to find out if it works fill a rectangle with black pixels
  19. for(int x=0; x<100; x++)
  20. for(int y=0; y<100; y++)
  21. img.setPixel(QPoint(x,y), Qt::black);
  22.  
  23. QGraphicsPixmapItem pmi(QPixmap::fromImage(img));
  24. m_scene->addItem(&pmi);
  25. show();
  26. }
To copy to clipboard, switch view to plain text mode 

* and part of the main code;

Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6.  
  7. m_geometry = new cGeometry();
  8. m_viewer = new cGeometryViewer(ui->frameMain);
  9. m_viewer->setGeometry(m_geometry);
  10. }
To copy to clipboard, switch view to plain text mode 

Thanks in advance!
Rob