QWidget::paintEngine: Should no longer be called
-
I am trying to make a simple widget that can show videos.
I have#include "video.h" #include <QVideoWidget> Video::Video(QWidget* parent, QString videofile) : QVideoWidget(parent) { player = new QMediaPlayer(this); player->setMedia(QUrl::fromLocalFile(videofile)); player->setVolume(50); player->setVideoOutput(this); } void Video::play() { player->play(); } Video::~Video() { if (player) delete player; }
And then I get the message:
QWidget::paintEngine: Should no longer be calledWhat am I doing wrong?
-
Hi
Well it might not be your fault :)But one thing is wrong
player = new QMediaPlayer(this); << the "this" is a parentand will delete anything it owns. Most of Qt works this way.
So you very rarely need to delete manually anything you give a parent.
so don't delete the player manually, as your Video class will do it.
This ownership system is explained here
https://doc.qt.io/qt-5/objecttrees.html -
Hi.
And thank you.
You make a good point. But I guess that's not the reason.
What do you mean - it might not be your fault? -
@Jakob-Clausen
"by not your fault" I mean that i see no use of QPainter in the code shown so
it could be QMediaPlayer that does something wrong unless there far more
code to Video , you didnt show. -
Yes, then just ignore it for now.
What Qt version and platform are you on ?
This used to be a bug. Didnt track it so not sure it was fixed at some point.
You could try player->stop(); via a button to test if that makes the error go away
-
@Jakob-Clausen
Oh, so its not even when you close or anything ?
Well, then, i think it's still the same bug as it sounds like how it was reported from other users.
It should be safe to ignore it. -
Ok.
Thank you very much for your help.
Have a nice weekend. :-) -
@Jakob-Clausen
Same to you :)
Also please use the "Topic Tool" button to set this as solved. ( in first post, to the right )