On 12.03.2012 11:27, manoj jangra wrote:
> I'm getting warnings (Unable to assign [undefined] to QString text)
> while trying to load data into a gridmenu in QML from C++ files.
> In QML file I load this data by declaring source as
> "source:model.image". and set the model data from C++ file.
> Data is loaded successfully but I'm getting warnings as mentioned above.
> Can anyone please help me out in getting rid of these warnings??
you don't give much information here, but probably your QML item is
created before the model data has been created by the C++ code. So in
the meantime some strings are bound to undefined values, that's why you
get the warning. You have to make sure, that the data is available when
your QML stuff is instantiated or at least initialize it with empty strings.
Best regards
Sven
_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
On 03/12/2012 11:27 AM, ext manoj jangra wrote:
> Hello All,
> I'm getting warnings (Unable to assign [undefined] to QString text)
> while trying to load data into a gridmenu in QML from C++ files.
> In QML file I load this data by declaring source as
> "source:model.image". and set the model data from C++ file.
> Data is loaded successfully but I'm getting warnings as mentioned above.
> Can anyone please help me out in getting rid of these warnings??
You might want to check in the binding if the string value you try to
assign is valid.
eg.
Text {
text: myValue ? myValue : ""
}
Regards,
Johannes
On 13.03.2012 06:47, manoj jangra wrote:
> Thanks for your valuable suggestion, it worked fine in most of the cases
> where i was setting text values from model data.
> But I still have same issue with "model" property in QML ListView.
> I tried setting model value as suggested by you:
> model:myModel?myModel:""
>
> But its still giving me warning which says "ReferenceError: Can't find
> variable: myModel"
>
> I'm getting the data but want to get rid of this warning; is there any
> way i can do it??
Did you read my email? ;-)
Sven
On 13.03.2012 11:32, manoj jangra wrote:
> Hi Seven,
> Yes, I saw your email; thanks for the comments. The problem is same, QML
> is initialized before setting data in C++.
That's the problem. You need to set the data before or while (e.g. in
the constructor of a C++ implemented QML item) the QML is initialized.