I know it's an old thread (4 years), but others may find it through a search engine, like I did, trying to find a solution.
What worked for me was to do this:
Instead of using QVideoWidget, use a QGraphicsView:
Create a sub-class of QGraphicsView (say, MyGraphicsView)
Create a QGraphicsScene, adding to the graphics view (setScene)
Create a QGraphicsVideoItem and add it to your scene (addItem)
Set the player output to the graphics video created on step 3
Override paintEvent on your subclass and do your drawing
Here is some sample code:
@MyGraphicsView *view = new MyGraphicsView(this);
QGraphicsScene *scene = new QGraphicsScene(view);
QGraphicsVideoItem *item = new QGraphicsVideoItem();
view->setScene(scene);
scene->addItem(item);
player->setVideoOutput(item);@
Now, for the paintEvent:
@void MyGraphicsView::paintEvent(QPaintEvent *e)
{
QGraphicsView::paintEvent(e);
QPainter painter(this->viewport());
// Do your drawing.
// For e.g., draw a rectangle:
painter.setPen(Qt::black);
painter.drawRect(10, 10, 200, 200);
}@