Question

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?

Was it helpful?

Solution

It is more common to make the QPainter a local instance in the paintEvent() function.

QPainter painter(this);

This results in the begin() and end() methods being called automatically. These are necessary for the QPainter to work correctly. You could try calling them manually in the paintEvent() to see if that makes a difference.

Another thing you might try for overlaying text on the video is to create a QLabel in code and make your video widget its parent. This does not require sub classing the video widget or overriding the paint event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top