W
W
WTFAYD2017-11-23 18:27:45
Qt
WTFAYD, 2017-11-23 18:27:45

Why does TypeError: Cannot read property '...' of undefined occur?

In general terms, I have a FlowChart element whose p1 and p2 properties need to be controlled from the SensorValuesSetter element using text fields.
The implementation of the SensorValuesSetter element is in another file.

// SensorValuesSetter.qml
ApplicationWindow {
        id: valueSetterWindow

        // ...

        GridLayout {
            // ...

            Label { text: "Давление 1: "; Layout.fillWidth:true; }
            ValueInputField { id: p1_val_field; }   

            Label { text: "Давление 2: "; Layout.fillWidth:true; }
            ValueInputField { id: p2_val_field; }   

            // ....

            Button {
                id: button
                text: qsTr("Применить")
                onPressed: {
                    valueSetterWindow.parent.p1.value = Number.fromLocaleString(p1_val_field.text)
                    valueSetterWindow.parent.p2.value = Number.fromLocaleString(p2_val_field.text)
                    // ...
        }
}


// main.qml

// ...

FlowChart {  
        id: flowChart
        anchors.fill: parent


        SensorValuesSetter {
            id: valueSetterWindow
        }

        // ...
    
}

However, when filling one of the values, an error occurs: TypeError: Cannot read property '[property]' of undefined
Please tell me why this error occurs and how to overcome it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question