I have a basic code but it's impossible to send a property to an external page
This is my main.qml :
PageStack {
id: pageStack
Component.onCompleted: push(pageMain)
Page {
title: i18n.tr("Main page")
id:pageMain
Button {
objectName: "button"
width: parent.width
text: i18n.tr("send value")
onClicked: {
var codeValue = "3029330003533";
console.log("code = " + codeValue);
pageStack.push(Qt.resolvedUrl("qml/view.qml", {code: codeValue}));
}
}
}
}
And my qml/view.qml page
import QtQuick 2.4
import Ubuntu.Components 1.2
Page {
title: "View"
id: pageView
property string code:"";
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
Label {
id: label
objectName: "label"
text: pageView.code
}
}
}
property "barcode" is always empty, where is my mistake ?
You parens aren't quite right:
Try making your property name a string, like this:
{'code': codeValue}
, otherwise Qml is likely trying to evaluate code as a variable rather than a literal.