Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

use a function in qml from another qml

$
0
0
welcome to forum. Did you create the instance of second qml component inside the first qml ? You need create instance, assign the id and through id you need to call. Try this. === TestFunction.qml==== Rectangle {     width: 100     height: 100     function callme(val, val){         console.log("I am called man="+val + " ok="+val)     } } ====== main.qml======== Rectangle {     width: 640     height: 480       TestFunction{         id : func     }       Button {         text: qsTr("Hello World")         anchors.horizontalCenter: parent.horizontalCenter         anchors.verticalCenter: parent.verticalCenter         onClicked: {             func.callme("pthinks.com","Bangaluru")         }     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles