I tried to achieve this using QLabel and re-implementing the resizeEvent:
#include <QtGui>
class MaskedLabel
: public QLabel{
protected:
{
pixmap.fill(Qt::transparent);
paintEvent(&pe);
setMask(pixmap.mask());
}
};
int main(int argc, char* argv[])
{
QLabel* label
= new MaskedLabel
();
label->setText("Qt Centre!");
QFont font
= label
->font
();
font.setPointSize(72);
label->setFont(font);
label->show();
return a.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
We placed this MaskedLabel over the QWebView widget and tts showing us the video playing in the background but when I tried to resize the QLabel using setGeometry() method its not showing me video on full QLabel but to some parts.
NOTE: when I just moved the QLabel (not changing width and height) using setGeometry(), I can still see the video in background. The video vanished only when I try to resize it.
Why resizing remove the video and show transparent QLabel?
Bookmarks