[SOLVED] Best method to display a stream of QImage's
-
Hi all, id like to know which method is the most efficient to display Qimages - i have tried both and they seem pretty similar so far and want to know if there are ways to optimize them, or different better methods to go about this.
#1 having a QLabel in my QVBoxLayout and calling:
@canvas->setPixmap(QPixmap::fromImage(img));@
whenever there is a new frame.
#2 using a QGraphicsView in my QVBoxLayout and then using
@
scene->clear();
scene->addPixmap(QPixmap::fromImage(img));
@both seem pretty CPU intensive.
Thanks, Tim. -
I would go with QGraphicsView, and draw QImages in its paint event.
@ QImage img;
QPainter p(this);
p.drawImage(rect(), img);@You could set some flags like: @p.setRenderHint(QPainter::SmoothPixmapTransform, true);@
-
Thanks, i did end up doing that - except i just have a QGraphicsItem which i keep calling
@
QGraphicsPixmapItem::setPixmap(QPixmap::fromImage(img));
@Is this way going to be more or less as quick as your paint method?
also what exactly would that flag do?
-
I don't know about the speed, its could be just as fast I guess. The method I suggested draws an image under 1ms. The flag I mentioned is used to get a better quality when scaling image.
-
Ok cheers Puksec! i might as well give both of them a go!