Efficient way of displaying a continuous stream of QImages

后端 未结 3 559
故里飘歌
故里飘歌 2020-12-16 06:47

I am currently using a QLabel to do this, but this seems to be rather slow:

void Widget::sl_updateLiveStreamLabel(spImageHolder_t _imageHolderShPtr) //slot         


        
3条回答
  •  囚心锁ツ
    2020-12-16 06:57

    Setting up a QGraphicsView and QGraphicsScene is quite straight-forward: -

    int main( int argc, char **argv )
    {
        QApplication app(argc, argv);
    
        // Create the scene and set its dimensions
        QGraphicsScene scene;
        scene.setSceneRect( 0.0, 0.0, 400.0, 400.0 );
    
        // create an item that will hold an image
        QGraphicsPixmapItem *item = new QGraphicsPixmapItem(0);
    
        // load an image and set it to the pixmapItem
        QPixmap pixmap("pathToImage.png") // example filename pathToImage.png
        item->setPixmap(pixmap);
    
        // add the item to the scene
        scene.addItem(item);
    
        item->setPos(200,200); // set the item's position in the scene
    
        // create a view to look into the scene
        QGraphicsView view( &scene );
        view.setRenderHints( QPainter::Antialiasing );
        view.show();
    
        return app.exec();
    }
    

提交回复
热议问题