How to read a property of a QtObject in list
-
I have something like:
property var listGraphs: [] QtObject { id: graph property string xmin: "-20" property string xmax: "20" property string zmin: "-20" property string zmax: "20" } -------- listGraphs.push(graph) -------- listGraphs[0].xmin // error undefined
What should be the correct sintax in the last line to read the properties of the QtObject ?
-
I have something like:
property var listGraphs: [] QtObject { id: graph property string xmin: "-20" property string xmax: "20" property string zmin: "-20" property string zmax: "20" } -------- listGraphs.push(graph) -------- listGraphs[0].xmin // error undefined
What should be the correct sintax in the last line to read the properties of the QtObject ?
import QtQuick 2.12
import QtQuick.Window 2.12Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")property var listGraphs: [] QtObject { id: graph property string xmin: "-20" property string xmax: "20" property string zmin: "-20" property string zmax: "20" } Component.onCompleted: { listGraphs.push(graph) console.log( listGraphs[0].xmin) }
}
-
import QtQuick 2.12
import QtQuick.Window 2.12Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")property var listGraphs: [] QtObject { id: graph property string xmin: "-20" property string xmax: "20" property string zmin: "-20" property string zmax: "20" } Component.onCompleted: { listGraphs.push(graph) console.log( listGraphs[0].xmin) }
}
@johngod you should put the last 2 statements in a function and call it.you are using the syntax of a property for a function which is wrong
-
@johngod you should put the last 2 statements in a function and call it.you are using the syntax of a property for a function which is wrong
@Ronel_qtmaster I did that, the code I posted was cutted for simplicity. Either way it started to work, maybe it just needed some qmake clean up. Thanks.
-
J johngod has marked this topic as solved on