스-나는 어떻게 얻을 수 있습니다.currentText 에서 또 다른 구성 요소는?

0

질문

나는 그냥을 배우기 시작했스와는 방법에 대한 질문이 있을 얻을 수 있습니다.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 ko 에서 설정 페이지에서 사용하는 구성 요소 id:lastPage

어떤 도움이 될 것이 크게 감사

combobox components embedded qml
2021-11-17 09:11:20
1

최고의 응답

0

실제로 나는 당신이 원하는 무엇이 있는 성분을 사용하여 여기서(응용 프로그램,NavigationStack etc.) 그러나 일반적으로 구조체처럼 될 수 있습니다 다음과 같다:

Window {
    visible: true   
    width: 400
    height: 300
    id: root
    property color someColor: "green"

    Row {
        id: element1
        anchors.centerIn: parent
        Rectangle {
            width: 100
            height: 100
            color: root.someColor
        }

        Rectangle {
            id: element2
            width: 100
            height: 100
            color: "yellow"
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    root.someColor = "blue"
                }
            }
        }
    }
}

element1 에 따라 일부 시설 부모로부터/최 항목에서 항상 범위가 있습니다. 이라 건설 property bindings 에스를 할 수 있는 여러 가지 방법으로(예를 들어 사용하는 바인딩을 위해 좋은 동적 요소가). 이 element2 도 액세스할 수 있/변경을 제공하고 그래서 그것을 변경하에서 element2 즉각 영향을 미치 element1. 는 또한 문제를 해결합니스에 액세스하려는 경우 element1rootelement1 지 않는 범위에서,또는 존재하지 않거나 무엇이든 것이 충돌을 응용 프로그램에서 이 경우입니다.

2021-11-17 11:29:59

Window 에 상관 없기에,나는 그냥 보여주고 싶었어요 개념,작동 예시
folibis

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................