如何在其他 qml 文件的主 qml 文件中使用 qml 类型

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

我在 main.qml 文件中有一个 TextField

main.qml

ApplicationWindow {
    id: mainWindow

 header: ToolBar{
    id: tbMain

    TextField{
        id: tfsearch
    }
}
}

main.qml 文件中,我有 StackView,我将 searchresult.qml 添加到此堆栈视图。

我想知道 searchresult.qml 如何使用 main.qml

中 TextField 的 textchanged 信号和文本 属性

searchresult.qml中:

Connections {
  target: tfsearch
  onTextChanged: doStuff()
}