Hello, I am trying to build a GUI for my OpenCV program. I would like to use Graphic View to display the processed image from OpenCV.

However, as a Qt newbie I am stuck with the basic usage of displaying a pixmap (which I planned to use for my OpenCV images). Following is the the C++ code I wrote to display a 100x100 pixel red pixmap. "gui" is the UI created with Designer (which contains a Qgraphicsview widget). The code compiles but when it runs the pixmap is not shown.

Please tell me what is wrong my code and how should I correct it. Thank you for your help!

Qt Code:
  1. gui.setupUi(this);
  2. QGraphicsScene GCSscene;
  3. QPixmap* GCSpixmap = new QPixmap(100,100);
  4. GCSpixmap->fill(QColor(255,0,0));
  5. QGraphicsPixmapItem* GCSpixmapitem = GCSscene.addPixmap(*GCSpixmap);
  6. (gui.graphicsView)->setScene(&GCSscene);
  7. (gui.graphicsView)->show();
To copy to clipboard, switch view to plain text mode