Play a video with custom overlay graphics

♀尐吖头ヾ 提交于 2019-11-28 06:34:34

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4473709/play-a-video-with-custom-overlay-graphics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!