Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. [QObjectList] Cannot read property 'forEach' of null in javascript
Forum Updated to NodeBB v4.3 + New Features

[QObjectList] Cannot read property 'forEach' of null in javascript

Scheduled Pinned Locked Moved Unsolved QtWebEngine
8 Posts 4 Posters 2.6k Views 2 Watching
  • 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.
  • Z Offline
    Z Offline
    zosskr
    wrote on last edited by
    #1

    Hi,
    I got "Cannot read property 'forEach' of null" error message from javascript when I try to list of QObjectList using forEach.

    Do you know how to enumerate the list of QObject from QObjectList in javascript?

    Looks like "forEach" is not supported.

    Thank you.

    JonBJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      A standard loop should work fine:

      for (var i = 0; i < list.length; ++i) {
        console.log(list[i])
      }
      

      Also, try Qt 5.12.1, JS support was improved there, perhaps forEach would work.

      (Z(:^

      Z 2 Replies Last reply
      0
      • Z zosskr

        Hi,
        I got "Cannot read property 'forEach' of null" error message from javascript when I try to list of QObjectList using forEach.

        Do you know how to enumerate the list of QObject from QObjectList in javascript?

        Looks like "forEach" is not supported.

        Thank you.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @zosskr said in [QObjectList] Cannot read property 'forEach' of null in javascript:

        Cannot read property 'forEach' of null" error message

        That implies in any case that your QObjectList variable is null, so you need to check that first....

        Z 1 Reply Last reply
        1
        • sierdzioS sierdzio

          A standard loop should work fine:

          for (var i = 0; i < list.length; ++i) {
            console.log(list[i])
          }
          

          Also, try Qt 5.12.1, JS support was improved there, perhaps forEach would work.

          Z Offline
          Z Offline
          zosskr
          wrote on last edited by
          #4

          @sierdzio : Thank you for the answer. I will check with your suggestions. :)

          1 Reply Last reply
          0
          • JonBJ JonB

            @zosskr said in [QObjectList] Cannot read property 'forEach' of null in javascript:

            Cannot read property 'forEach' of null" error message

            That implies in any case that your QObjectList variable is null, so you need to check that first....

            Z Offline
            Z Offline
            zosskr
            wrote on last edited by
            #5

            @JonB : Thank you for the answer. I already verified the object is valid. I think QObjectList is not supported in 5.12.0 for JS. may need to check with higher version.

            JKSHJ JonBJ 2 Replies Last reply
            0
            • sierdzioS sierdzio

              A standard loop should work fine:

              for (var i = 0; i < list.length; ++i) {
                console.log(list[i])
              }
              

              Also, try Qt 5.12.1, JS support was improved there, perhaps forEach would work.

              Z Offline
              Z Offline
              zosskr
              wrote on last edited by
              #6

              @sierdzio Unfortunately, Qt 5.12.1 does not work also.

              1 Reply Last reply
              0
              • Z zosskr

                @JonB : Thank you for the answer. I already verified the object is valid. I think QObjectList is not supported in 5.12.0 for JS. may need to check with higher version.

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                @zosskr said in [QObjectList] Cannot read property 'forEach' of null in javascript:

                I think QObjectList is not supported in 5.12.0 for JS.

                QObjectList is definitely supported by QJSEngine in Qt 5.12.

                How did you pass the list into JavaScript?

                I already verified the object is valid.

                How did you do that?

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                1
                • Z zosskr

                  @JonB : Thank you for the answer. I already verified the object is valid. I think QObjectList is not supported in 5.12.0 for JS. may need to check with higher version.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @zosskr
                  I am with @JKSH on this: how do you actually know the object is valid? Because when JS says

                  "Cannot read property 'forEach' of null" error message from javascript when I try to list of QObjectList using forEach.

                  that (should) mean that the lhs of whatever you are calling forEach() on has the value null....

                  1 Reply Last reply
                  1

                  • Login

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