Search code examples
qtqmlqtquick2signals-slots

How use qml types in main qml file from other qml file


I have a TextField in main.qml file

main.qml

ApplicationWindow {
    id: mainWindow

 header: ToolBar{
    id: tbMain

    TextField{
        id: tfsearch
    }
}
}

in main.qml file I have StackView that I add searchresult.qml to this stackview.

I want to know in searchresult.qml how use textchanged signal and text property of TextField that is in main.qml


Solution

  • In searchresult.qml:

    Connections {
      target: tfsearch
      onTextChanged: doStuff()
    }