How to Two overlapping QVideowidgets with transparency
-
Hi,
I would like to play two videos simultaneously and have the Output mixed. I'm using QT 5.2 on Windows 8.1 with MinGW 4.8. My approach is as follows:
@ playerA = new QMediaPlayer(this);
playerB = new QMediaPlayer(this);videoWidgetA = new VideoWidget(this); playerA->setVideoOutput(videoWidgetA); videoWidgetB = new VideoWidget(this); playerB->setVideoOutput(videoWidgetB); QBoxLayout *displayLayout = new QHBoxLayout; displayLayout->addWidget(videoWidgetA); videoWidgetB->setParent(videoWidgetA); // Position videoWidgetB that it covers 1/4 of videoWidgetA videoWidgetB->setGeometry(0,0,480,270); displayLayout->setMargin(0); setLayout(displayLayout); playerA->setMedia(QUrl::fromLocalFile("x:/Videos/1.wmv")); playerB->setMedia(QUrl::fromLocalFile("x:/Videos/2.wmv")); videoWidgetB->setWindowOpacity(0.5); videoWidgetA->setWindowOpacity(0.5); playerA->play(); playerB->play();@
VideoWidgetB opacity is allways 1.0 and VideowidgetA is not visible were videoWidgetB covers the screen, there is no transparency.
The serious this is if I append
@ this->setWindowOpacity(0.5);@
then I can see the desktop through videoWidgetA and videoWidgetB, but not videoWidgetA through videoVidgetB.
Hope my text is not to confusing.