我开始学习QML,我收到以下错误:
ReferenceError:未定义chatTextArea
我有一个全局函数,它通过id在同一个QML文件中对某个项执行某些操作.
出于某种原因,我无法通过TextArea的ID或SplitView中的任何项目进行访问.但我能够操纵TabView和每个Tab的属性.
我的破码:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
Rectangle {
id: lobby
function appendChatMsg(msg) {
chatTextArea.append(msg) //causes: ReferenceError: chatTextArea is not defined
}
TabView {
id: frame
Tab { //I CAN access this item via ID.
id: controlPage
SplitView {
anchors.fill: parent
TableView {
Layout.fillWidth: true
}
GridLayout {
columns: 1
TextArea { //This item I CANNOT access via ID.
id: chatTextArea
Layout.fillHeight: true
Layout.fillWidth: true
}
TextField {
placeholderText: "Type something..."
Layout.fillWidth: true …Run Code Online (Sandbox Code Playgroud)