-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.2
-
None
-
Windows 10
Calling QWidget::winId() before setting the attibute WA_TranslucentBackground, prevents the window from being transparent. However doing the opposite works as intended.
This code creates a window with a transparent background:
TransparentWindow::TransparentWindow()
: QWidget()
{
setAttribute(Qt::WA_TranslucentBackground);
qDebug() << "id: " << winId();
qDebug() << "WA_TranslucentBackground: " << testAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);
setLayout(new QHBoxLayout(this));
QPushButton* button1 = new QPushButton(this);
button1->setFixedSize(100, 30);
layout()->addWidget(button1);
QPushButton* button2 = new QPushButton(this);
button2->setFixedSize(30, 100);
layout()->addWidget(button2);
}
However inverting those two lines makes the background black:
qDebug() << "id: " << winId();
setAttribute(Qt::WA_TranslucentBackground);
In all cases the attribute WA_TranslucentBackground is correctly set to true.