Qt Quick2 window can't be transparent without aero

。_饼干妹妹 提交于 2019-12-23 01:36:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!