1

I want to play a video (with sound) in a simple GUI with "play" and "stop" buttons etc. There are classes and widgets in Qt's Phonon module for doing that, and several examples. OK, so that seems to be simple.

But now I need to draw some custom graphics (that depend on the current time in the video) on top of the streamed video image. I have not found anything about this in the Qt documentation. What's the canonical way of doing this? Do I just create a custom VideoWidget widget and override its paintEvent? In another question here, some guy seemed to have trouble with this.

Any pointers would be appreciated.

Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70

2 Answers2

2

Use QGraphicsView and QGraphicsWidgets. You can put your Phonon::VideoWidget inside a QGraphicsProxyWidget and it becomes usable as a QGraphicsWidget.

For custom overlays, inherit QGraphicsWidget and override the paint function to draw your custom widgets. You can add them to your scene and they will appear on top of your video widget.

Vicken Simonian
  • 411
  • 4
  • 6
1

Your solution cannot work because you cannot add a QGLWidget to QGraphicsProxyWidget. Please look at http://doc.qt.digia.com/qt/qgraphicsproxywidget.html

Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller cannot be embedded. Examples are QGLWidget and QAxWidget.

Please correct me if I'm wrong.

Boeckm
  • 3,264
  • 4
  • 36
  • 41
  • It has been some time since I implemented this, and I don't have access to the code right now. But I can reassure you that I did indeed solve it. As far as I remember, I did solve it as described in the accepted answer, but I may be wrong. – Sebastian Negraszus Nov 07 '12 at 15:39
  • Thank you for your quick reply Sebastian. I am very pleased to here that it worked for you. Do think it would be possible to get access the code in the next time and add it (or just the important snippet) to this post? – user1773762 Nov 08 '12 at 07:21
  • I think it would be interresting everyone here to see how this can done – user1773762 Nov 12 '12 at 08:38