QML - TypeError
-
wrote on 11 Sept 2011, 04:01 last edited by
Hello there. Does anyone know how to solve this error?
@TypeError: Result of expression 'item' [null] is not an object.@
I can't seem to call my QML. Help?
Thank you :)
-
wrote on 11 Sept 2011, 06:44 last edited by
Can you show code where this error happened?
-
wrote on 11 Sept 2011, 07:50 last edited by
Here:
@if (typeof item.activationComplete != 'undefined') item.activationComplete();@
and
@if (typeof item.deactivationComplete != 'undefined') item.deactivationComplete();@I'm trying to imitate the ViewLoader QML of this project:
-
wrote on 11 Sept 2011, 07:58 last edited by
Where definition of 'item' variable?
if you can't be sure that item exists in thi place, you should rewrite this lines as:@if (typeof(item) != 'undefined' &&
typeof(item.activationComplete) != 'undefined') item.activationComplete();
@and
@if (typeof(item) != 'undefined' &&
typeof(item.deactivationComplete) != 'undefined') item.deactivationComplete();
@ -
wrote on 11 Sept 2011, 08:15 last edited by
I think this is what you're looking for:
@Item {
id: contentPane
clip: true
anchors {
top: titleBar.bottom
left: mainWindow.left
right: naviBarVertical.left
bottom: naviBarHorizontal.top
}@and after that block I put this:
@ ViewLoader {
id: windowView
viewSource: "windowView.qml"
keepLoaded: true
}@ -
wrote on 11 Sept 2011, 10:40 last edited by
I' still not see object with name 'item'.
-
wrote on 11 Sept 2011, 12:55 last edited by
I can't find it. :O
-
wrote on 11 Sept 2011, 13:11 last edited by
[quote author="FlyingFish" date="1315745736"]I can't find it. :O[/quote]
I think interpreter can't find it too :)
Well... What object do you expect in this place?
or show more your source code.
-
wrote on 11 Sept 2011, 14:48 last edited by
What do you mean what object?
@ function activationComplete() {
Util.log("activationComplete");
// if (typeof item.activationComplete != 'undefined') item.activationComplete();
if (typeof(item) != 'undefined' &&
typeof(item.activationComplete) != 'undefined') item.activationComplete();
}function deactivationComplete() { Util.log("deactivationComplete"); // if (typeof item.deactivationComplete != 'undefined') item.deactivationComplete(); if (typeof(item) != 'undefined' && typeof(item.activationComplete) != 'undefined') item.activationComplete(); if (!keepLoaded) source = ""; }@
and that's basically it.
-
wrote on 11 Sept 2011, 17:59 last edited by
What we need to see is your Item definition, else it is very difficult to contextualize your function.
BTW, a general advice when the type error happens is that it can depend by the fact that at the time you check for something on that objet it is not yet loaded completeley (this means that not all the properties are set.). Try to move your control functions in onComponent.completed: { } to be sure that the Item is really loaded as you expect in the QML document. Then see if the error happens again and share with us the Item definition.
-
wrote on 13 Sept 2011, 15:46 last edited by
My Item definition? I'm sorry, I'm not good with terms. I'm still a beginner. Did you mean the visual styles that I put?
-
wrote on 13 Sept 2011, 16:01 last edited by
I think that Vass meant correct.
[quote author="Vass" date="1315746660"][quote author="FlyingFish" date="1315745736"]I can't find it. :O[/quote]
I think interpreter can't find it too :)
Well... What object do you expect in this place?
or show more your source code.[/quote]Please share your code where the example you wrote refers to.
BTW, you write in above:
@
[...]
typeof(item.activationComplete)
[...]
@What is this item???
1/12