PDA

View Full Version : non-existent property error



nuliknol
3rd May 2014, 10:58
Hi,
I have created a component in a file "Tabc.qml", like this:


import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Window 2.1
import QtQuick.Controls 1.1

Rectangle {
width: parent.width
property int company_id: 0
}

Then in javascript I load the component like this:

onRegisterCompany: {
var component=Qt.createComponent("Tabc.qml");
component.company_id=company_id;
companies_tab.addTab(company_name,component);
console.log("company_id is ",company_id);
}

but when javascript code is executed, I get this error:


file:///home/niko/qtdev/build-forms-Desktop_Qt_5_2_1_GCC_64bit-Debug/qml/forms/main.qml:51: Error: Cannot assign to non-existent property "company_id"

why do i get the non-existent property error if I defined the property in Tabc.qml file ???
Would appreciate very much your comments.
Regards

anda_skoa
3rd May 2014, 16:53
I think you are missing the createObject() call
http://qt-project.org/doc/qt-4.8/qml-component.html#createObject-method

Cheers,
_

nuliknol
3rd May 2014, 18:44
thanks! this is exactly what I was missing