简体   繁体   English

覆盖Phonon.VideoWidget的最佳实践是什么?

[英]What is the best practice to overlay a Phonon.VideoWidget?

The last couple of days I have tried to find a working solution to overlay a Phonon.VideoWidget with a simple QLabel. 最近几天,我试图找到一个可行的解决方案,以使用简单的QLabel覆盖Phonon.VideoWidget。 Sadly I wasn't able to find a working solution. 可悲的是,我找不到有效的解决方案。

Here is what I have tried: 这是我尝试过的:

  1. Parenting. 育儿。 I tried the "normal" parenting stuff addressing the QLabel to the VideoWidget. 我尝试了将QLabel寻址到VideoWidget的“常规”育儿方法。 Result: The label does not show up at all. 结果:标签根本没有显示。

  2. QStackedLayout. QStackedLayout。 As suggested here: http://www.qtcentre.org/threads/31490-Overlaying-Widgets-on-top-of-VideoWidget . 如此处的建议: http : //www.qtcentre.org/threads/31490-Overlaying-Widgets-on-top-of-VideoWidget Result: Label is shown but always behind the video 结果:显示标签,但始终在视频后面

  3. GraphicsView. GraphicsView。 I tried a lot here as it looked like the most promising, but at the end the CPU load was just too high so the video did not play back. 我在这里尝试了很多,因为它看起来是最有前途的,但是最后CPU负载太高,因此无法播放视频。 Setting the view's viewport to QGLWidget did not solve it. 将视图的视口设置为QGLWidget并不能解决。 Result: Overlay works but video does not play caused by high CPU load. 结果:覆盖有效,但由于CPU负载过高而无法播放视频。

  4. Subclassing the VideoWidget. 子类化VideoWidget。 As mentioned here: https://wiki.qt.io/Overlay_widget_for_Phonon_VideoWidget . 如此处所述: https : //wiki.qt.io/Overlay_widget_for_Phonon_VideoWidget I took the same approach to create the overlay. 我采用了相同的方法来创建叠加层。 This works just fine after all, except for the moveEvent. 毕竟,除了moveEvent之外,这一切都很好。 It does not look nice if the label is realigned after moving the widget has finished. 如果在移动小部件完成后重新对齐标签,效果会不太好。 Is there a way to update this already when moving VideoWidget? 移动VideoWidget时是否已经有方法进行更新?

I really hope someone can help me here (I use PySide but examples in C++ should work as well) or give me a pointer on where to look. 我真的希望有人可以在这里为我提供帮助(我使用PySide,但C ++中的示例也应该起作用),或者为我提供了查找位置的指针。 Please let me know if I should share some code snippet to reproduce. 请让我知道我是否应该共享一些代码段以进行重现。

The best you can do is creating a new window that floats above your video widget. 最好的办法是创建一个新窗口,该窗口浮在视频窗口小部件上方。 For example create a parentless QLabel and make sure that it moves in sync with your main window. 例如,创建一个无父母的QLabel并确保它与您的主窗口同步移动。

label = new QLabel();
label->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);

In your QMainWindow subclass, override moveEvent and resizeEvent and do something like: 在您的QMainWindow子类中,覆盖moveEvent和resizeEvent并执行以下操作:

label->move(mapToGlobal(QPoint(0, height() - label->height())));

This keeps the label in the bottom-left corner, change it to fit your needs. 这样可以将标签保留在左下角,并根据需要进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 声子VideoWidget错误:“视频小部件无法正确初始化” - Phonon VideoWidget error: “the video widget could not be initialized correctly” Phonon的VideoWidget在QGLWidget上显示错误的颜色(Qt,Python) - Phonon's VideoWidget show wrong colors on a QGLWidget (Qt, Python) Python Selenium Chrome 网络驱动程序。 持续检查网页上是否发生叠加的最佳做法是什么? - Python Selenium Chrome webdriver. What is the best practice to continuously check if overlay happens on a webpage? 使用Phonon和PyQt将视频与自定义图形叠加 - Overlay video with custom graphics using Phonon & PyQt 在这种情况下,最佳代码实践是什么? - What is the best code practice in this case? Django元数据数据库的最佳实践是什么? - What is the best practice on the metadatabase for Django? python连接到postgresql的最佳实践是什么? - What is the best practice for python connecting to postgresql? 在Python中解析参数的最佳做法是什么? - What is the best practice for parsing arguments in Python? 使用生成器进行计数的最佳实践是什么 - What is best practice to use generators for counting purposes python存储库模式中“查找”的最佳实践是什么? - What is the best practice for 'find' in the python repository pattern?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM