1

I am currently writing a real-time visualization tool for processing simulation data. The data are two-dimensional data like a pressure/temperature field. Currently, I am using QImage to manipulate the data and QPixmap to display those data but are there any better/faster way? Does QPixmap::fromImage() copy the data from the given image and how costly is that? The source code from my approach looks like this:

int main(int argc, char **argv) {
    QApplication app(argc, argv);
    QMainWindow* mainWindow = new QMainWindow(0, 0);
    mainWindow->setMinimumSize(1024, 768);
    mainWindow->show();
    QGraphicsScene* scene = new QGraphicsScene();
    QGraphicsView* view = new QGraphicsView(scene);
    mainWindow->setCentralWidget(view);

    QImage* image = new QImage(640, 480, QImage::Format_RGB32);
    image->fill(0);

    QGraphicsPixmapItem* item = scene->addPixmap(QPixmap::fromImage(*image));

    item->setPos(0, 0);
    // DO SOME CALCULATION AND SET PIXEL COLOR ON image
    item->setPixmap(QPixmap::fromImage(*image));
return  app.exec();
Bui Thanh Binh
  • 103
  • 1
  • 10
  • You can get and display the input using one item -and custom painting. no need for a QImage. Btw, Qt Charts also use the graphicsview framework and is well optimized, you might want to take a look at that. – baci Jul 02 '16 at 09:58

0 Answers0