我有一個sddm主題的組件。目前我使用主題黑糖作為基礎主題。該組件如下所示:
Item {
id: hexagon
property color color:"yellow"
property int radius: 30
//layer.enabled: true
//layer.samples: 8
Shape {
//... Here some Positioning and other Stuff
ShapePath {
//... Here some Options and Pathlines
}
}
}
這很好用,但是一旦我取消注釋這兩個layer設定,組件就會消失。是否會發生這種情況,因為我像這樣加載組件:
Pane {
...
Item {
...
MyComponent {
z: 1
}
}
}
窗格或專案也不使用layer,但專案中的大多陣列件都使用該z: 1屬性。
uj5u.com熱心網友回復:
正如 iam_peter 所說,任何 Item 的默認寬度和高度屬性都是 0,并且 layer.enabled 將螢屏外紋理的大小設定為專案大小。默認情況下,場景圖不進行任何裁剪:子項可以填充其父項邊界之外的場景圖節點。但是,當您將孩子的渲染限制在特定的螢屏外紋理時,任何不適合的內容都會被剪裁。這是一個更具互動性的示例:
import QtQuick
import QtQuick.Controls
Rectangle {
width: 640
height: 480
Column {
CheckBox {
id: cbLE
text: "layer enabled"
}
Row {
spacing: 6
TextField {
id: widthField
text: layerItem.width
onEditingFinished: layerItem.width = text
}
Label {
text: "x"
anchors.verticalCenter: parent.verticalCenter
}
TextField {
id: heightField
text: layerItem.height
onEditingFinished: layerItem.height = text
}
}
}
Rectangle {
id: layerItem
x: 100; y: 100
border.color: "black"; border.width: 2
layer.enabled: cbLE.checked
Rectangle {
width: 100
height: 100
color: "tomato"
opacity: 0.5
}
Text {
text: "this text will get clipped even when layer size is defined"
}
}
}
您可以使用 renderdoc 查看渲染是如何完成的;例如,您可以看到通過啟用圖層創建的紋理。
uj5u.com熱心網友回復:
這是一個可重現的小例子:
import QtQuick
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Item {
//width: 200
//height: 200
//layer.enabled: true
Rectangle {
width: 100
height: 100
color: "red"
}
}
}
我懷疑如果您沒有在Item要啟用圖層(layer.enabled: true)的位置上設定大小,它的大小將為 0。因此,螢屏外緩沖區的大小為 0。
附帶說明一下,這在沒有層的情況下有效,因為默認情況下將clipan 的屬性設定為 false。Item所以它不會剪輯到其父級的邊界。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/514830.html
標籤:qtqml抗锯齿
