如何制作 "True Transparent" window 光标,最好是在纯 QML 上? (Qt 5.7)
How to make a "True Transparent" window to cursor, preferably on a pure QML? (Qt 5.7)
"True Transparency" explanation (image, 76kb).
在那个图像 ApplicationWindow 上有一个视觉透明层。但实际上,光标并没有转到ApplicationWindow后面的window(在本例中为QT Creator)。
"True Transparency" 如果添加(取消注释)"Qt.WindowTransparentForInput" 标志,但按钮不再可用(我知道这很明显)。
我尝试了各种具有相似含义的标志(来自文档),但没有找到有效的组合 - 游标在 window 的边界内时保持 "default" 状态(必须处于 "text" 状态,因为它下面是文本)。
有人遇到过类似的问题吗,你找到解决办法了吗?谢谢!
来自图像的代码,其他项目文件保持不变(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 windows,一个用于透明区域,一个用于每个按钮。
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"
}
}
}
"True Transparency" explanation (image, 76kb).
在那个图像 ApplicationWindow 上有一个视觉透明层。但实际上,光标并没有转到ApplicationWindow后面的window(在本例中为QT Creator)。
"True Transparency" 如果添加(取消注释)"Qt.WindowTransparentForInput" 标志,但按钮不再可用(我知道这很明显)。
我尝试了各种具有相似含义的标志(来自文档),但没有找到有效的组合 - 游标在 window 的边界内时保持 "default" 状态(必须处于 "text" 状态,因为它下面是文本)。
有人遇到过类似的问题吗,你找到解决办法了吗?谢谢!
来自图像的代码,其他项目文件保持不变(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 windows,一个用于透明区域,一个用于每个按钮。
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"
}
}
}