Does QML posses this QMl type logic?
-
I am wondering is there anything in QMl that behaves like the following thing I am calling "elementX":
elementX { id: thisElement listOfElementValues { value: x label: y foo: qsTr("Bar") } }
such that I can now access those properties like so:
onClicked: { if(thisElement.foo === "Bar") { //do some logic } }
-
@fcarney I am not sure I understand how this will work. Perhaps I just don't know what I am doing. Can I pass around the id of "elementX" for instance, to a component?
What I have is a function which I am calling. The function will create a separate component and I want to be able to pass the model into that component, for instance:
ListModel { id: myModel ListElement { value: 3 unit: "ft" minValue: 0 maxValue: 100 label: "Label" } } onClicked: { //the component showNumericKeyboard("someString", [qsTr("Cancel"), qsTr("Finished")], myModel); }
Now, in the
showNumericKeyboard
component I would like to have access to:value
,unit
, etc... I am not sure how I can do that s/t I can use those properties of myModel like to display a value to the user or what-have-you. So in the keypad component:TextStyled { id: idHeaderText anchors.fill: parent style: control.style.styleTextHeader wrapMode: Text.WordWrap text: myModel.label }
-
ListView { width: 180; height: 500 model: myModel delegate: Text { text: label + ": " + value + " " + unit } MouseArea { onClicked: { // stuff } } }
The delegate is where you do something for each item in the list. Are you looking for multiple objects or just one? Maybe QtObject is what you want:
QtObject { id: obj property int value: 3 // other vars }