Hi,
I have a piece of code that dynamically generates (from javascript) a form. In the example below the form only contains one textfield but the use-case i have is more complicated. There is also a button which should gather the information inside the form and do something with it. The button is outside the dynamic creation. The problem I face is that button doesnt know what’s inside and the dynamic form doesnt know what’s outside. Trying to access properties from either side results insome ‘unknown’ property … error.
ApplicationWindow {
visible: true
width: 800
height: 600
property var currentAppForm : null
property string formQML : "import QtQuick 2.2; import QtQuick.Controls 1.1;import QtQuick.Layouts 1.1; \
TextField {id : pin_0; text : \"blup\"}"
function createform() {
if (currentAppForm != null) currentAppForm.destroy(0)
currentAppForm = Qt.createQmlObject(formQML, theparent, "autoform2");
console.debug("done2")
}
Action{
id : doit
onTriggered: {
if ( currentAppForm != null)
console.debug("do something with the content of the dynamic created form")
}
}
Action{
id : doform
onTriggered: {
createform()
}
}
Column {
width : 200
height : 400
Button{
text : "make form"
action: doform
}
Button{
text : "press me"
action: doit
}
Rectangle{
id : theparent
width : 500
height : 300
border.width: 1
}
}
}
↧