正如我所理解的,Qt5Compat.GraphicalEffects中有一个Qt5Compat.GraphicalEffects,在QtQuick.Shapes中有一个,.I想用Qt6中的Gradient填充Shape,但是属性名称有一个错误。我还需要在qml中导入这两个模块,那么如何使用从QtQuick.Shapes中指定的模块呢?
发布于 2022-09-02 08:29:12
https://doc.qt.io/qt-6/qtqml-syntax-imports.html#importing-into-a-qualified-local-namespace
import QtQuick
import QtQuick.Shapes
import Qt5Compat.GraphicalEffects as GE
Window {
width: 640
height: 480
visible: true
color: "white"
title: qsTr("ConicalGradient")
Item {
width: 300
height: 300
GE.ConicalGradient {
anchors.fill: parent
angle: 0.0
gradient: Gradient {
GradientStop { position: 0.0; color: "white" }
GradientStop { position: 1.0; color: "black" }
}
}
}
Shape {
width: 200
height: 150
anchors.centerIn: parent
ShapePath {
strokeWidth: 0
strokeColor: "transparent"
fillGradient: ConicalGradient {
angle: 0.0
centerX: 100
centerY: 75
GradientStop { position: 0; color: "blue" }
GradientStop { position: 0.2; color: "green" }
GradientStop { position: 0.4; color: "red" }
GradientStop { position: 0.6; color: "yellow" }
GradientStop { position: 1; color: "cyan" }
}
startX: 20
startY: 20
PathLine { x: 180; y: 130 }
PathLine { x: 20; y: 130 }
PathLine { x: 20; y: 20 }
}
}
}https://stackoverflow.com/questions/73569418
复制相似问题