问题
I'm using Qt 5.7 on Windows 7.
I can make my QWindow have opacity, but it can't be transparent.
// window1.qml
Window {
width: 640
height: 480
color: "transparent"
} // no transparent, black background
// window2.qml
Window {
width: 640
height: 480
color: "transparent"
opacity: 0.5
} // black but 50% opacity background
But if I enable aero, then it would be transparent without any problem.
I've read a lot of articles about it. but I couldn't find correct answer.
https://stackoverflow.com/a/22554797/6356562 - set surface format
This answer doesn't work for me.
How can I solve it?
回答1:
I tried this code with Qt 5.8
:
Window {
width: 200
height: 200
visible: true
color: "transparent"
opacity: 0.9
Button {
anchors.centerIn: parent
text: "Click Me!"
}
}
And I get this result:
I recommend you use Qt 5.8
.
来源:https://stackoverflow.com/questions/42059468/qt-quick2-window-cant-be-transparent-without-aero