Pixmap::fromImage the mistery.
-
Hello.
I'm working on receiving data from gstreamer in QT widgets and I found one surprise:
I create an QImage from gstreamer data and create a QPixmap from that image to display the data like this:
QPixmap pixmap;
pixmap.fromImage (image);and display the data:
ui->imageLabel->setPixmap(pixmap);and it does not display any data...
but if I use:
ui->imageLabel->setPixmap(QPixmap::fromImage(image)); instead of ui->imageLabel->setPixmap(pixmap);It does display the data I'm expected to see.
Does anyone have an idea why is this behaving like that ?
I thought that pixmap.fromImage(image) returns exacly the same results as QPixmap::fromImage(image).
-
QPixmap::fromImage()
is a static function which returns the QPixmap. -
Yeea, that's what I missed reading the docs. Thanks a lot !
-
@Seba-the-student said in Pixmap::fromImage the mistery.:
QPixmap pixmap;
pixmap.fromImage (image);Replace to:
QPixmap pixmap;
pixmap = QPixmap::fromImage (image);
You must hold data from image somewhere. -
Hi and welcome to devnet,
If working with video, recent versions of Qt allows to use custom GStreamer pipelines so why not take advantage of that rather that doing things manually ?