I am trying to draw strings while I have a video palying, like a subtitle…
I have a Phonon::QVideoWidget, in its constructor I do:
painter = new QPainter(this);
and I have overrided the paint event to this, only for test:
void MyVideoWidget::paintEvent(QPaintEvent* event)
{
painter->drawLine(0, 0, 1, 1);
//painter-> anything shows
}
So when I start my player I see nothing that QPainter did, only the normal video playing
any ideas?
It is more common to make the
QPaintera local instance in thepaintEvent()function.This results in the
begin()andend()methods being called automatically. These are necessary for theQPainterto work correctly. You could try calling them manually in thepaintEvent()to see if that makes a difference.Another thing you might try for overlaying text on the video is to create a
QLabelin code and make your video widget its parent. This does not require sub classing the video widget or overriding the paint event.