ฉันเพิ่งเริ่มเรียนรู้ qml และมีคำถามว่าจะเอากล่องคอมโบ.currentText จากอีกส่วนประกอบ.
รหัสตัวอย่าง:
App {
id: app
width: px(250); height: px(250)
NavigationStack {
Page {
id: page
navigationBarHidden: true
AppText { text: "startpage" }
SimpleButton{
x: 220; y: 0; onClicked: page.navigationStack.push(settingsPage)
}
AppText {
x: 0; y: 50; text: "text " + comboBox1.currentText
}
}
}
Component {
id: settingsPage
Page {
navigationBarHidden: true
AppText { text: qsTr("settings page") }
SimpleButton{
x: 220; y: 0; onClicked: page.navigationStack.push(lastPage)
}
ComboBox {
id: comboBox1
currentIndex: 0
x: 10; y: 40
style: ComboBoxStyle {
label: Text {
text: control.currentText
}
}
model: ListModel {
ListElement { text: "green" }
ListElement { text: "dark-green" }
ListElement { text: "blue" }
}
}
AppText {
x: 0; y: 90; text: "text " + comboBox1.currentText
}
}
}
Component {
id: lastPage
Page {
navigationBarHidden: true
AppText { text: qsTr("last page") }
SimpleButton{
x: 220; y: 0; onClicked: page.navigationStack.push(page)
}
AppText {
x: px(50); y: px(90); text: "text " + comboBox1.currentText
}
}
}
}
->ฉันต้องการให้คอนที่เลือกไว้ออ Listelement อกจากกล่องคอมโบนใน settingspage และใช้มันในส่วนประกอบหมายเลข:lastPage
ที่เขาแนะนำให้ผูกผ้ากันเปื้อนจะเป็น greatly รู้สึกขอบคุณ
Window
ไม่สำคัญหรอยู่ที่นี่ฉันแค่อยากจะแสดงคอนเซ็ปต์ทำงานเป็นตัวอย่างเช่น