Hi, >From what I remember, TabView uses a Loader to load each Tab lazily. So if you attempt to reference an Item inside the Loader (i.e. the Tab) from outside the Loader, its not going to work.
If you find this is the case, it might help to expose whatever you want to access as a property in the root Item in your Tab and then use the TabView's currentIndex property and getTab from outside. Something like main.qml- TabView { FancyTab {} function printUsername() { var tabItem = getTab(currentIndex).item; console.log(tabItem.username); } } FancyTab.qml- Item { property alias username: usernameText.text TextField { id: usernameText } } On Sat, Dec 5, 2015 at 4:10 AM, Mike Jackson <imikejack...@gmail.com> wrote: > I am working on a QML application and after the last issues were solved I > am attempting to refactor the code so that common sets of QML codes are in > their own .qml files. > > The issue that I am having is that now that I am using TabView{} and > associated “Tab” widgets, when I go to reference a TextField that is buried > down in one of the tabs I get the “ReferenceError: minZThickness_TF is not > defined” error. If I move that QML object as a child of the root QML object > then things work, but obviously the display is now busted. Has anyone else > seen anything like this before? I’ll attach my QML file to the end for the > curious. > — > Mike Jackson > > > import QtQuick 2.4 > import QtQuick.Controls 1.4 > import QtQuick.Layouts 1.2 > > Rectangle > { > id: rectangle > width: 800 > // Make the background a bit lighter > color: "Light Gray" > border.color: "Black" > objectName: "RootObject" > > //--------------- > // These Variables are related to the Small IN100 Campaign. > // --------------- > Item { > id: experimentParams > property real minZThickness: 4.0 > property int targetGrainCount: 0 > > function toJSON() { > experimentParams.minZThickness = > parseFloat(minZThickness_TF.text) > experimentParams.targetGrainCount = > parseInt(targetGrainCount_TF.text) > return '"Small IN100" : {' + > '"minZThickness": ' + experimentParams.minZThickness + > ',' + > '"targetGrainCount": ' + > experimentParams.targetGrainCount + > '}'; > } > } > > TabView { > id: tabView_ > anchors.right: parent.right > anchors.bottom: parent.bottom > anchors.top: parent.top > anchors.left: parent.left > antialiasing: true > > > Tab { > id: experimentTab > title: "Grain Count Parameters" > anchors.topMargin: 12 > ScrollView > { > id: scrollView_ > anchors.top: parent.top > anchors.left: parent.left > anchors.right: parent.right > anchors.bottom: parent.bottom > > > GridLayout > { > id:gridLayout0_ > columns: 2 > columnSpacing: 5 > rowSpacing: 10 > property int scrollBarSpacing: 20 > width: scrollView_.width - scrollBarSpacing > flow: GridLayout.LeftToRight > > Text { text: qsTr("Target Grain Count:") } > TextField > { > id: targetGrainCount_TF > Layout.fillWidth: true > text: experimentParams.targetGrainCount > onEditingFinished: > experimentParams.targetGrainCount = targetGrainCount_TF.text > } > Text { text: qsTr("Min. Z Thickness:") } > TextField > { > id: minZThickness_TF > Layout.fillWidth: true > text: experimentParams.minZThickness > onEditingFinished: experimentParams.minZThickness > = minZThickness_TF.text > } > } > } > > } > > } > > > // This function creates the JSON that will be transmitted through out > the network > // to gather data from the instruments and pass that data to the > Analysis Engine > // It should include all the elements from the "Item" above. > function makeJson() > { > return experimentParams.toJSON(); > } > > > } > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > -- Shantanu Tushar (UTC +0530) shantanu.io
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest