qt - 如何更改 QML ApplicationWindow Overlay 大小?
问题描述
因为可以为元素Qt 5.10
设置Overlay
附加属性。Popup
这里有一个示例https://doc.qt.io/qt-5/qml-qtquick-controls2-overlay.html#modal-attached-prop。对于需要更改背景以Popup
将dim:
属性设置为true
. 但是(至少对我而言)我不知道如何更改Overlay
大小。例如,我有一个自定义ApplicationWindow
覆盖contents:
属性能够在窗口上绘制阴影(我的自定义窗口没有边框)并放置MouseArea
在边框之外以模仿本机窗口的行为。可悲的部分是 -Overlay
绘制在整个窗口区域上,这使得超出边界的区域变得丑陋。
有谁知道在使用dim:
属性时调整覆盖大小(我的意思是至少背景阴影)的方法Popup
?
这是一个典型的Popup
代码:
Popup {
id: popupReleaseNotes
x: Math.round(parent.width/2 - width/2)
y: Math.round(parent.height/2 - height/2)
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
modal: true
dim: true
}
在这里你可以看到它在我的应用程序中的样子:
覆盖背景超出了我的自定义边界,这意味着它占据了所有ApplicationWindow
区域。这就是我想要改变的。到目前为止,我没有找到任何记录的方式。
解决方案
我建议你使用 ColorOverlay。
https://doc.qt.io/qt-5/qml-qtgraphicaleffects-coloroverlay.html
无论如何,在我看来,您错过了 Overlay.Modal。阅读文档(),我期待的是:
Popup {
id: popupReleaseNotes
x: Math.round(parent.width/2 - width/2)
y: Math.round(parent.height/2 - height/2)
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
modal: true
visible: true
Overlay.modal: Rectangle {
anchors.fill: parent
color: "#aacfdbe7"
}
}
PS 查看 Popup 及其布局,以了解可能是内容项与背景的问题。也许您的调光是在比内容更大的背景上完成的。 https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html
推荐阅读
- jquery - 背景容器 Div 超链接
- java - 在 Spring Boot 控制器中反序列化枚举忽略大小写
- php - 如何创建基于加密货币的 woocommerce 多供应商商店?
- opendaylight - OpenDayLight Oxygen Netconf 挂载数据丢失错误
- sql - Bigquery 活跃用户计数不准确(谷歌分析)
- node.js - 使用伊斯坦布尔时,MongoDB 中的日期字段偏移一小时
- json - 使用 Ajax 将 JSON 作为 POST 发送到 Django
- python - 原始 wav 字节到 uint 数组或其他格式
- php - 类金额未找到贝宝
- durandal - Durandal:使用路由获取当前页面 URL