如何将javascript属性传递给不是文本或数字的qml对象。我想将属性传递给设置属性文本的c++属性的值。
var component;
var gauge;
function createVerticalGauge(setWidth,setX,setY,setID,setText,setValue) {
component = Qt.createComponent("verticalbargauge.qml");
console.log(component.status)
if (component.status == Component.Ready)
finishCreation(setWidth,setX,setY,setID,setText,setValue);
else
component.statusChanged.connect(finishCreation);
}
function finishCreation(setWidth,setX,setY,setID,setText,setValue) {
if (component.status == Component.Ready) {
gauge = component.createObject(adaptronicDash, {"id": setID, "gaugetext": setValue,
"x": setX, "y": setY});
gauge.width = setWidth;
if (gauge == null) {
// Error Handling
console.log("Error creating object");
}
} else if (component.status == Component.Error) {
// Error Handling
console.log("Error loading component:", component.errorString());
}
}
通过以下调用调用JS:
Component.onCompleted: CreateVerticalGaugeScript.createVerticalGauge(300,10,300,"map","MAP",Dashboard.MAP);
仪表板地图
设置对象的文本特性。
当直接在QML文件中创建对象时,将使用仪表板设置文本。映射,但没有脚本,它只是“0”。
仪表板MAP是一个qreal,它来自类仪表板,为我的qml对象提供值:
Q_PROPERTY(qreal MAP READ MAP WRITE setMAP NOTIFY MAPChanged)
如何通过仪表板。使用javascript映射。在我的例子中
设置值
有价值
qml:未定义