Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Unable to assign [undefined] to QQuickItem*
Forum Updated to NodeBB v4.3 + New Features

Unable to assign [undefined] to QQuickItem*

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 3 Posters 1.6k Views
  • 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.
  • R Offline
    R Offline
    Rohith
    wrote on last edited by Rohith
    #1

    Hello,

    There is small implementation in my code where i am trying to assign a property var to ShaderEffectSource Item, posting the code for better understanding

    Screen.qml

    Flickable {
            anchors.fill: parent
            contentHeight: flickItem.height
            clip: true
            flickableDirection: Flickable.VerticalFlick
            boundsBehavior: Flickable.StopAtBounds
    
            Item {
                id: flickItem
                ListView {
                    id: list
    
                    delegate: Item {
                           //Some Implementation is there here 
                            ShaderEffectSource {
                                id: option
                                anchors.left: parent.left
                                anchors.top: parent.top
                                anchors.bottom: parent.bottom
                                width: parent.width/2
                                sourceItem: PageRegister.get(index) //getting warning at this line Unable to assign [undefined] to QQuickItem*
                            }
    
                            Connections {
                                target: PageImageRegistry
                                onItemInserted: {
                                    if (itemIndex === index) {
                                        option.sourceItem = PageRegister.get(index)
                                    }
                                }
                            } 
                       }
                  }
            }
    }
    

    PageRegister.qml

    pragma Singleton
    import QtQuick 2.9
    
    QtObject {
    
        property var store: new Object
        property string key: "key"
    
        function get(index) {
            var str = key + index
            return store[str]
        }
    
        function insert(item, index) {
            var str = key + index
            store[str] = item
            itemInserted(index)
        }
        signal itemInserted(int itemIndex)
    }
    

    Can some one please help to resolve the error.

    Thanks in advance !!

    Regard's,
    Rohith.G

    1 Reply Last reply
    0
    • J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Rohith said in Unable to assign [undefined] to QQuickItem*:

      what is

      PageImageRegistry

      ?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      R 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @Rohith said in Unable to assign [undefined] to QQuickItem*:

        what is

        PageImageRegistry

        ?

        R Offline
        R Offline
        Rohith
        wrote on last edited by
        #3

        Hi @J-Hilk,
        Apologies, it should be PageRegister i have corrected the same.

        J.HilkJ 1 Reply Last reply
        0
        • R Rohith

          Hi @J-Hilk,
          Apologies, it should be PageRegister i have corrected the same.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Rohith

          I thought as much, never the less, you still need an instance of PageRegister and refer to it via the id you give it. It won't work with just the class name :D


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          R 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @Rohith

            I thought as much, never the less, you still need an instance of PageRegister and refer to it via the id you give it. It won't work with just the class name :D

            R Offline
            R Offline
            Rohith
            wrote on last edited by
            #5

            Hi @J-Hilk
            The PageRegister contains a pragma of Singleton, if possible can you please post a sample code. I started to work on qml newly.

            Thanks in advance !!

            J.HilkJ 1 Reply Last reply
            0
            • R Rohith

              Hi @J-Hilk
              The PageRegister contains a pragma of Singleton, if possible can you please post a sample code. I started to work on qml newly.

              Thanks in advance !!

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Rohith said in Unable to assign [undefined] to QQuickItem*:

              The PageRegister contains a pragma of Singleton

              oh, didn't see that
              didn't know it existed and omg, can't say I like the existence of it either.

              are you sure this:

              function get(index) {
                      var str = key + index
                      return store[str]
                  }
              

              does what you think it does ?


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              R 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @Rohith said in Unable to assign [undefined] to QQuickItem*:

                The PageRegister contains a pragma of Singleton

                oh, didn't see that
                didn't know it existed and omg, can't say I like the existence of it either.

                are you sure this:

                function get(index) {
                        var str = key + index
                        return store[str]
                    }
                

                does what you think it does ?

                R Offline
                R Offline
                Rohith
                wrote on last edited by
                #7

                Hi @J-Hilk ,

                I hope it does because i am not seeing the warning all the time, and what i understood from the code snippet they are trying to got an object with the selected index value.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Reddy_12
                  wrote on last edited by Reddy_12
                  #8

                  Hi @J-Hilk ,

                  Can I know how we can get this warning resolved as we cannot create an instance of pageRegister due to pragma of singleton .

                  May I know if there is any other way to achieve the same.

                  Thanks in Advance.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved