ReferenceError in qt quick controls tabview

半腔热情 提交于 2019-12-01 12:27:40

Pass the object as a parameter

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.1

ApplicationWindow {
    function show_text(myobject) {
        console.log(myobject.text)
    }

    TabView {
        id: tv
        Tab {
            id: tab1
            Button{
                id: b1
                text: "b1's text"
                onClicked: {
                    show_text(b1)
                }
            }
        }
    }
}

You can access in your object with this example.

ApplicationWindow {
function show_text() {
    console.log(tv.b1Text);
}

TabView {
    id: tv
    property alias b1Text: b1.text
    Tab {
        id: tab1
        Button{
            id: b1
            text:"b1's text"
            onClicked: {
                //console.log(b1.text)
                show_text()
            }
        }
    }
}

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!