#include <QtGui>
class MaskedLabel : public QLabel
{
protected:
void resizeEvent(QResizeEvent* event)
{
QLabel::resizeEvent(event);
QPixmap pixmap(size());
pixmap.fill(Qt::transparent);
QPainter::setRedirected(this, &pixmap);
QPaintEvent pe(rect());
paintEvent(&pe);
QPainter::restoreRedirected(this);
setMask(pixmap.mask());
}
};
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QLabel* label = new MaskedLabel();
label->setText("Qt Centre!");
QFont font = label->font();
font.setPointSize(72);
label->setFont(font);
label->show();
return a.exec();
}
Hi,
I tired this approach to create Picture In Picture(PIP) window on QWebView widget. And my goal is to create hole on QwebView so that video playing in the background is visible through PIP window.
When I first create this Masked Label its showing me the video playing in background, all is good at this point. But when I try to change the height/width of the Masked Label using setGeometry() method of QLabel, its is not showing me transparent window. But when I only(not changing the height/widht) move it around on the screen using same setGeometry(), it just work fine.
Any idea OR approach to achieve my goals.
Thanks.