如何在 QML 中更改 SVG 的颜色

问题描述 投票:0回答:1

我有一个 QML 控件来显示 .svg 图片。我希望 .svg 的颜色适合我的用户定义主题。但我不知道如何改变 svg 的颜色。

我有一个像这样的

Image control
,但我没有
color property
。我该怎么办?

Image {
    id: icon
    anchors{
        top: parent.top
        bottom: parent.bottom
        right: parent.right
    }
    width: height
        source: "../Image/BxChevronDown.svg"
}
svg qml
1个回答
0
投票

我已经得到答案:应该使用 ColorImage

ColorImage {
        id: icon
        anchors{
            top: parent.top
            bottom: parent.bottom
            right: parent.right
        }
        width: height
        source: "../Image/BxChevronDown.svg"
        color: theme.themeColor0
    }

在此输入图片描述

© www.soinside.com 2019 - 2024. All rights reserved.