Can not overlay a transparent Qlabel on a QWidget

2019-08-05 07:53发布

问题:

I have a question to LibVLC users that I have been struggling all day but couldn't come to a solution yet, so wanted to ask you for help.

I have a Qt application that uses LibVLC to play videos, video streams. As you may know, LibVLC uses Qt widgets to render video frames by getting only the WinID of the Qwidget and handles the rest itself. I have a Qwidget to render video with LibVLC and I want to overlay a transparent Qlabel on this widget but when the widget starts showing the video, the label can not be transparent and stays with a background with the very last thing it was overlaying before the video starts to play.

This is a LibVLC issue to me and I am sure there is a solution but couldn't find a work around on the net so far.

Any suggestions why this happens and how to avoid?

Thanks in advance.

回答1:

adding these attribute and flag to the desired Qlabel solved my problem.

labelCamName->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
labelCamName->setAttribute(Qt::WA_TranslucentBackground);