“真正的透明”解释(图片,76kb).
在那张图片上应用窗口有一个视觉上透明的层。但实际上光标并没有走到后面的窗口应用窗口(在本例中为 QT Creator)。
如果添加(取消注释)“Qt.WindowTransparentForInput”标志,则可以实现“真正的透明度”,但按钮不再可用(我知道,这是显而易见的)。
我尝试了具有类似含义的各种标志(来自文档),但没有找到有效的组合 - 当光标位于窗口边框内时,光标保持在“默认”状态(必须处于“文本”状态,因为是其下方的文字)。
有人遇到过类似的问题吗?您找到解决方案了吗?谢谢!
来自图像的代码,其他项目文件保持不变(Qt Quick Controls 2 应用程序):
import QtQuick 2.7
import QtQuick.Controls 1.5
ApplicationWindow {
visible: true
width: 320
height: 240
x: 400
y: 210
color: "transparent"
flags: Qt.Widget | Qt.FramelessWindowHint //| Qt.WindowTransparentForInput
//| Qt.WA_TranslucentBackground //| Qt.WA_NoSystemBackground
//| Qt.WA_NoBackground //| Qt.WA_MouseNoMask
Button {
x: ApplicationWindow.width - width
text: "Right Top Window Corner"
}
Button {
y: ApplicationWindow.height - height
text: "Left Bottom Window Corner"
}
}
一种解决方案是创建 3 个窗口,一个用于透明区域,一个用于每个按钮。
import QtQuick 2.4
import QtQuick.Controls 1.5
import QtQuick.Window 2.0
ApplicationWindow {
id: app
visible: true
width: 320
height: 240
x: 400
y: 210
color: "transparent"
flags: Qt.Widget | Qt.FramelessWindowHint | Qt.WindowTransparentForInput | Qt.WindowStaysOnTopHint
Window {
visible: true
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
x: app.width - width
height: rightButton.implicitHeight
Button {
id: rightButton
text: "Right Top Window Corner"
}
}
Window {
visible: true
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
y: app.height - height
height: leftButton.implicitHeight
Button {
id: leftButton
text: "Left Bottom Window Corner"
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)