设置字体大小图例 ChartView QML

Set fontSize legend ChartView QML

我需要你的帮助。我在qml中做一个ChartView,我不能设置字体大小。我阅读了文档,但没有找到任何解决方案。

有没有设置图例字体大小的方法??

ChartView {
    id:chartView
    title: "Haccp Data"
    theme: ChartView.ChartThemeDark
    backgroundColor: "black";
    width: parent.width;
    height: parent.height
    anchors.fill: parent
    antialiasing: true;
    visible: true
    legend.markerShape: Legend.MarkerShapeCircle

    ....
}

我看到有一个 属性 :

legend.font: Font.pointSize(8) //for example

但更改此 属性 值没有任何效果。 有什么建议吗?

谢谢

根据文档判断,正确的语法是:

legend.font.pointSize: 120

如果碰巧你也设置了

legend.font.pixelSize

此设置具有 documentation 中所述的优先级。

注意直截了当

legend.font.pointSize: 120

当您为图表指定主题时不起作用,就像在原始问题中所做的那样。

在这种情况下

Component.onCompleted...

@derM 建议的方法是我发现唯一可行的解​​决方法。谢谢@derM.