Paint over QVideoWidget
-
Symbian/Maemo phones, Qt 4.6.3.
I use QMediaPlayer for playing and QVideoWidget for displaying streaming video.
Now I'm trying to display some additional info over the video, for example video title, duration etc.
Is it somehow possible to put other widgets or paint on top of the QVideoWidget? -
-
Ok, I need to build my Qt with Phonon support, but tried this quickly to check if this would work:
@
QPushButton *btn = new QPushButton(ui->label);
btn->setText("click me");
btn->setGeometry(5,5,20,20); // wrt the parent label
btn->setVisible(true);
qDebug() << btn->geometry();
@
and it does ... but have to fix my env first and try this with QVideoWidget. I still think it should work... qDebug can chk if the geometry is right. -
Have You tried sub-classing QVideoWidget and implementing a paintEvent like so:
@--
void YourClass::paintEvent(QPaintEvent* e)
{
QVideoWidget::paintEvent(e);
QPainter painter(this);
//... painting what you need over the content rendered by QVideoWidgets paintEvent
}
@ -
toplevelwidget dialog on N900 blurs the screen, video motion is not seen.
toplevelwidget PushButton is displayed below video, even though it should be on the top.I've also tried to subclass QVideoWidget, but paintEvent method of new class is not called at all
during app running. This is strange, probably my mistake somewhere in the code. -
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);
}@