本页内容

HCandlestickModelMapper QML Type

用于K线序列的水平模型映射器。更多...

Import Statement: import QtCharts 2.12
Since: QtCharts 2.2
In C++: QHCandlestickModelMapper
Status: Deprecated

此类型已弃用。我们强烈建议不要在新代码中使用它。

属性

详细说明

模型映射器允许将从QAbstractItemModel 类派生的数据模型用作图表的数据源。 水平模型映射器用于在数据模型与CandlestickSeries 之间建立关联,使得数据模型中的每一行都定义一个K线项目,每一列则分别映射到该K线项目的开盘价、最高价、最低价、收盘价和时间戳值。

既可以使用模型属性,也可以使用K线序列属性来操作数据。模型映射器会保持K线序列与数据模型之间的同步。

模型映射器确保烛台序列中的所有烛台项大小一致。因此,向某个烛台项添加或移除一个值,会导致烛台序列中的所有烛台项发生相同的变更。

以下 QML 示例创建了一个包含三个 K 线项的 K 线序列(假设模型至少有四行)。每个 K 线项包含由时间戳、开盘价、最高价、最低价和收盘价列定义的数据。项的名称由行的垂直标题定义。

CandlestickSeries {
    HCandlestickModelMapper {
        model: myCustomModel // QAbstractItemModel derived implementation
        timestampColumn: 1
        openColumn: 2
        highColumn: 3
        lowColumn: 4
        closeColumn: 5
        firstSetRow: 1
        lastSetRow: 3
    }
}

另请参阅 CandlestickSeries 、CandlestickSet 以及VCandlestickModelMapper 。

属性文档

closeColumn : int

该模型中包含该系列中K线项目收盘值的列。默认值为-1(映射无效)。

firstSetRow : int

用作第一个项目数据源的模型行。默认值为 -1(映射无效)。

highColumn : int

该模型中包含该序列中K线项目高值的列。默认值为-1(无效映射)。

lastSetRow : int

用作最后一个项目数据源的模型行。默认值为 -1(映射无效)。

lowColumn : int

模型中包含该序列中K线项目低值的列。默认值为-1(无效映射)。

model : QAbstractItemModel

映射器所使用的基于QAbstractItemModel 的模型。该模型必须已实现并向QML公开。

注意: 所使用的模型 必须支持添加和删除行或列,以及修改单元格中的数据。

openColumn : int

该模型中包含该系列中K线项目开盘值的列。默认值为-1(映射无效)。

series : CandlestickSeries

映射器所使用的基于 CandlestickSeries 的对象。

将该系列设置为映射器时,系列中的所有数据都会被丢弃。当指定新系列时,旧系列将被断开连接(其数据将予以保留)。

timestampColumn : int

模型中包含该系列中K线项的时间戳值的列。默认值为-1(无效映射)。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.