Ho appena iniziato a imparare qml e ho una domanda su come ottenere il controllo comboBox.currentText da un altro componente.
esempio di codice:
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
}
}
}
}
-> Ho bisogno di avere selezionato Listelement dal Combobox in imposta pagina e l'utilizzo del componente con id: lastPage
Qualsiasi aiuto sarebbe molto apprezzato
Window
non importa qui, ho solo voluto mostrare il concetto, un esempio funzionante