我刚开始学习的最大似然有一个问题,就如何组合框。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从组合框在设置页:和使用它的成分与id:lastPage
任何帮助,将不胜感激
Window
问题不在这里,我只是想表现的概念,一个工作实例