
Originally Posted by
technoViking
Thanks so that seems to be sending a clicked() signal but I don't see how you can send a string through that signal and how does the other .qml file accept that signal, aka how does it make a slot to receive the string?
In QtQuick you usually use property binding which is a higher-level mechanism than signals and slots (and it uses signals under the hood in case of C++ code). Most of the times signals are used as notification of some property changes and all you need to do is to follow this pattern - you declare a property in one object and write a statement in the other object that uses the name of the property defined earlier.
Here is a dirty example:
import Qt 4.7
Rectangle {
id: win
width: 200
height: 200
TextInput {
anchors.top: win.top; anchors.left: win.left; anchors.right: win.right;
id: objectA
text: "xyz"
height: 100
}
Text {
id: objectB
anchors.bottom: win.bottom; anchors.left: win.left; anchors.right: win.right;
height: 100
text: "=>"+objectA.text+"<="
}
}
import Qt 4.7
Rectangle {
id: win
width: 200
height: 200
TextInput {
anchors.top: win.top; anchors.left: win.left; anchors.right: win.right;
id: objectA
text: "xyz"
height: 100
}
Text {
id: objectB
anchors.bottom: win.bottom; anchors.left: win.left; anchors.right: win.right;
height: 100
text: "=>"+objectA.text+"<="
}
}
To copy to clipboard, switch view to plain text mode
Try changing the text of the first object and see what happens.
Remember QML is a declarative language. You declare text of objectB to be the text of objectA surrounded by arrows.
Bookmarks