Change child windows element text or proporty
-
hi i have two qml file . one of them main.qml and other file users.qml
i can access users.title with command ornektext.text = userScreen.title
but i cant access id:username text.
how can change username id text ?@
main.qmlimport QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import "content"
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Adres Kayıt Ekranı")
ChildWindow { id: window1 }
Users { id:userScreen }
menuBar: MenuBar {
Menu {
title: qsTr("Adress")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
Menu {
title: "More Stuff"
MenuItem {
text: "Do Nothing"
onTriggered: window1.visible = !window1.visible
}
MenuItem {
text: "Yeni bir pencere aç "
onTriggered: {
userScreen.visible = !userScreen.visible
ornektext.text = userScreen.title
}
.....
.....
...
users.qmlimport QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
Window {
id:userScreen
width: 400
height: 400
title: "Kullanıcı Ekranı"
Rectangle {
id:cerceve
width: 400
height: 62
Text
{
id:username
text:qsTr("Mehmet")
}
}
}
@ -
Hi and Welcome,
Create a property in users.qml, bind it to username's text and then access this property from main.qml.
Also please keep indentation in code so that its easier for others to read. -
The scope of all "ids" in QML is local file. They are not visible outside a file. So you need to export your text as a property:
@
proerty string text: "something"
// ...
Text
{
id:username
text: userScreen.text
}// And to access it in main:
userScreen.text
@ -
thx sierdzio , thx p3c0
i solved problem.