QML - TypeError



  • 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 :)



  • Can you show code where this error happened?



  • 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:

    "https://projects.developer.nokia.com/QMLRestaurantApp"



  • 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();
    @



  • 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
    }@



  • I' still not see object with name 'item'.



  • I can't find it. :O



  • [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.



  • 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.



  • 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.



  • 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?



  • 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???


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.