[Interest] QML undefined Reference if object is in a TabView
Mike Jackson
imikejackson at gmail.com
Fri Dec 4 23:40:51 CET 2015
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();
}
}
More information about the Interest
mailing list