0

After a long search for the answer and a lot of testing I have not been able to place a QWidget (QLabel with a semitransparent image) over a QtGstreamer widget.

When I add an QLabel with an image over the QGst::Ui::VideoWidget (which displays video from RTP stream) the area covere with the label is black and does not display the video (which is playing).

I uploaded the project to GitHub https://github.com/MatijaBosnic/QtGstOverlay (updated the code. It is much simpler and easier to read now)

How can I overlay QGst::Ui::VideoWidget with another widget?

  • I looked at it and could not find any QLabel in the source code. Moreover the use of QPainter is not correct. If and when you need QPainter it is usually used from paint event for the "label". If you had real QLabel hovering over that widget then you would see it. And there is no problem to put in an image in QLabel as well. – Alexander V Sep 01 '17 at 06:37
  • Thank you for looking into my problem. The label is added in .ui file(line 37). I tried to add it by code with the same result. QPainter in the example is for painting an overlay, but that code is not used (the call to "doMagic" is commented out). – Matija Bosnic Sep 01 '17 at 07:32
  • If there is QLabel somewhere then it is probably under that other widget. Try to raise it or so: http://doc.qt.io/qt-5/qwidget.html#raise – Alexander V Sep 01 '17 at 14:42
  • I have cleaned up the example. Now you can see that there is a player widget. Then I add the label widget over the player. The part of the player that is covered by the label is black and does not show the video, while the other part does. QWidget:.raise() changes nothing since the widget is already on top. It is not in the code, but I tried it just to be 100% sure. – Matija Bosnic Sep 04 '17 at 06:35
  • What happens if you make the `QLabel` a top-level widget (no parent) -- does the video show through it? I'm not proposing this as a solution; just trying to understand the problem a bit more. – G.M. Sep 04 '17 at 09:42
  • It doesn't show the QLabel. For it to be show in the window, I have to add it to a layout (only QStackedLayout allows widget overlay) which automatically adds it as the labels parent. – Matija Bosnic Sep 04 '17 at 12:18
  • "It doesn't show the QLabel". Really? You'll have to call `overlayLabel->show()` explicitly since it's a top-level widget, but it should definitely appear. – G.M. Sep 04 '17 at 13:21
  • overlayLabel->show() displays the widget but in it's separate window beside (behind) the main window. – Matija Bosnic Sep 04 '17 at 14:22
  • That's expected but... when you move the `QLabel` over the video widget manually (using the mouse or whatever) does it appear as you would want it to -- semi-transparent etc.? – G.M. Sep 04 '17 at 14:45
  • The problem with compiling your example is that it needs QtGstreamer and not too many people have that installed. Maybe if you replace QtGStreamer window with normal Qt's own widget that the problem still shows? That we can compile easily. * I do some GStreamer for instance but I use my own classes and no QtGstreamer. – Alexander V Sep 05 '17 at 03:39
  • @G.M.No. It is a separate window and the window is not transparent. The widget is. I tried with a QPushButton and QMediaPlayer and the label is 100% transparent. – Matija Bosnic Sep 05 '17 at 07:50
  • @AlexanderVX The QtGstreamer is available in repositories on Ubuntu 16 which I'm using for this example. With Qt's widgets, there is no problem with overlay. But since QMediaPlayer does not support RTP streams (which are my requirement) I am forced to use something else. VLC was too slow for my application so that leaves me with Gstreamer. And I would very much like to use QtGstreamer wrapper. – Matija Bosnic Sep 05 '17 at 08:14

0 Answers0