QWidget::paintEngine: Should no longer be called
-
I try to capture a image of QVideoWidget using a grab()
But it capture a all black image.
and shows QWidget::paintEngine: Should no longer be calledplayer = new QMediaPlayer(this); vw = new QVideoWidget(this); player->setVideoOutput(vw); player->setMedia(QUrl("gst-pipeline: videotestsrc ! xvimagesink name=\"qtvideosink\"")); vw->setGeometry(240,80,1400,800); vw->show(); player->play(); qDebug() << "clicked" vw->grab().save("image.png");Any suggestion?
Thanks in advance.
-
I try to capture a image of QVideoWidget using a grab()
But it capture a all black image.
and shows QWidget::paintEngine: Should no longer be calledplayer = new QMediaPlayer(this); vw = new QVideoWidget(this); player->setVideoOutput(vw); player->setMedia(QUrl("gst-pipeline: videotestsrc ! xvimagesink name=\"qtvideosink\"")); vw->setGeometry(240,80,1400,800); vw->show(); player->play(); qDebug() << "clicked" vw->grab().save("image.png");Any suggestion?
Thanks in advance.
@nadimfnadaf said in QWidget::paintEngine: Should no longer be called:
player->play();
qDebug() << "clicked"
vw->grab().save("image.png");You're trying to grab the image right after calling play(). At that time there is probably nothing to grab yet.
Try to connect a slot to https://doc.qt.io/qt-5/qmediaplayer.html#stateChanged and grab the image as soon as the state changes to QMediaPlayer::PlayingState.