I am currently developing a video player.
The GUI as the topmost layer is written in QML. It should be transparent to the lower layers. It contains controls, some lists, etc. It is displayed using QDeclarativeView .
Description
QDeclarativeView *upperLayer = new QDeclarativeView(this); upperLayer->setSource(QUrl("/home/projects/QtVideo/qml/videoControl.qml")); upperLayer->setStyleSheet(QString("background: transparent"); upperLayer->setResizeMode(QDeclarativeView::SizeRootObjectToView); uperLayer->showFullScreen();
Layer under QWidget: I use libvlc to display video content in this widget.
Reason: I get MPEG-TS, which cannot be decoded by phonon, afaik. Therefore, I need libvlc to decode the incoming *.ts and display the output.
QWidget *lowerLayer = new QWidget(this); lowerLayer.setGeometry(QString("background: red")); QUrl* url = new QUrl("file:///home/projects/QtVideo/video.ts"); libvlc_instance_t*vlcObject; libvlc_media_t*vlcMedia; libvlc_media_player_t*vlcPlayer; vlcPlayer = NULL; if(vlcObject = libvlc_new(argc, argv)) == NULL) { printf("Not able to initialize"; exit(1); } if(vlcPlayer && libvlc_media_player_is_playing(vlcPlayer)) { libvlc_media_player_stop(vlcPlayer); } vlcPlayer = libvlc_media_player_new(vlcObject); vlcMedia = libvlc_media_new_location(vlcObject, url.toString().toUtf8().constData()); libvlc_media_player_set_media(vlcPlayer, vlcMedia); #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(vlcPlayer, lowerLayer->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_x_window(vlcPlayer, lowerLayer->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(vlcPlayer, lowerLayer->winId()); #endif libvlc_media_player_play(vlc_player);
Both elements, QDeclarativeView and QWidget are embedded in QMainWindow , the lower layer created before upperLayer , upperLayer Transparent for lowerLayer .
Problem:
As long as the bottom layer displays static elements, such as an image or some colored shapes, everything works fine, completely transparent and functional.
As soon as I start showing a video, for example, described *.ts using libvlc OR some random video using Phonon::VideoPlayer , the parts of the upperLayer that are above the lowerLayer video lowerLayer displayed in the color lowerLayer(default: gray) , parts of the correct behavior of the upperLayer that are located above parts of lowerLayer or others that do not contain video elements are displayed correctly.
Question:
Is there any possibility and if, how, to get a transparent top layer, even if there is a video game?