Reproducir un vídeo con superposición de gráficos personalizados
-
11-10-2019 - |
Pregunta
Quiero reproducir un vídeo (con sonido) en una sencilla interfaz gráfica de usuario con botones de "ventanilla única" de "juego" y etc Hay clases y widgets en el módulo Phonon de Qt para hacer eso, y varios ejemplos. Aceptar, por lo que parece ser simple.
Pero ahora necesito dibujar algunos gráficos personalizados (que dependen de la hora actual en el video) en la parte superior de la imagen de vídeo streaming de. No he encontrado nada sobre esto en la documentación de Qt. Cuál es la forma canónica de hacer esto? No acabo de crear una costumbre VideoWidget widget y anulan su paintEvent? En otra pregunta aquí, un tipo parecía tener problemas con esto.
sería apreciada Cualquier punteros.
Solución
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.
Otros consejos
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 areQGLWidget
andQAxWidget
.
Please correct me if I'm wrong.