Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QML - TypeError

    QML and Qt Quick
    3
    12
    13122
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      vsorokin last edited by

      Can you show code where this error happened?

      --
      Vasiliy

      1 Reply Last reply Reply Quote 0
      • F
        FlyingFish 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:

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

        1 Reply Last reply Reply Quote 0
        • V
          vsorokin 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();
          @

          --
          Vasiliy

          1 Reply Last reply Reply Quote 0
          • F
            FlyingFish 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
            }@

            1 Reply Last reply Reply Quote 0
            • V
              vsorokin last edited by

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

              --
              Vasiliy

              1 Reply Last reply Reply Quote 0
              • F
                FlyingFish last edited by

                I can't find it. :O

                1 Reply Last reply Reply Quote 0
                • V
                  vsorokin 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.

                  --
                  Vasiliy

                  1 Reply Last reply Reply Quote 0
                  • F
                    FlyingFish 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.

                    1 Reply Last reply Reply Quote 0
                    • Alicemirror
                      Alicemirror 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.

                      Enrico Miglino (aka Alicemirror)
                      Balearic Dynamics
                      Islas Baleares, Ibiza (Spain)
                      www.balearicdynamics.com

                      1 Reply Last reply Reply Quote 0
                      • F
                        FlyingFish 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?

                        1 Reply Last reply Reply Quote 0
                        • Alicemirror
                          Alicemirror 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???

                          Enrico Miglino (aka Alicemirror)
                          Balearic Dynamics
                          Islas Baleares, Ibiza (Spain)
                          www.balearicdynamics.com

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post