0

我在列布局中有一些标签,我想将 DropShadows 添加到其中。它有效,但我在控制台中不断收到错误以调整:file:///home/username/.local/share/plasma/plasmoids/org.kde.fancyclock/contents/ui/main.qml:117:9: QML DropShadow: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead

如何防止发生此错误?

我尝试将阴影移出列布局,并尝试将它们嵌套在标签中,但两者都会产生奇怪的副作用。这是一个 KDE 小部件。代码如下。

ColumnLayout {
    id: columns
    spacing: 10;
    width: root.width;
    
    PlasmaComponents.Label {
        id: timeLabel
        
        
        Layout.alignment: columns.horizontalCenter;
    }
     
    PlasmaComponents.Label {
        id: dateLabel
        
        // snip //
        
        Layout.alignment: columns.horizontalCenter;   
    }

    DropShadow {
        anchors.fill: timeLabel
        horizontalOffset: 3
        verticalOffset: 3
        radius: 8.0
        samples: 17
        color: "#80000000"
        opacity: timeOpacity;
    }

    DropShadow {
        anchors.fill: dateLabel
        horizontalOffset: 3
        verticalOffset: 3
        radius: 8.0
        samples: 17
        color: "#80000000"
        source: dateLabel
    }
}
       

所有代码都可以在:https ://github.com/tjaart/plasma-fancy-clock

4

0 回答 0