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

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

Scheduled Pinned Locked Moved Unsolved QtWebEngine
8 Posts 4 Posters 2.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.
  • Z Offline
    Z Offline
    zosskr
    wrote on 4 Feb 2019, 23:30 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.

    J 1 Reply Last reply 5 Feb 2019, 09:37
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 5 Feb 2019, 06:42 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 5 Feb 2019, 14:49
      0
      • Z zosskr
        4 Feb 2019, 23:30

        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.

        J Offline
        J Offline
        JonB
        wrote on 5 Feb 2019, 09:37 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 5 Feb 2019, 15:57
        1
        • S sierdzio
          5 Feb 2019, 06:42

          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 5 Feb 2019, 14:49 last edited by
          #4

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

          1 Reply Last reply
          0
          • J JonB
            5 Feb 2019, 09:37

            @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 5 Feb 2019, 15:57 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.

            J J 2 Replies Last reply 6 Feb 2019, 01:54
            0
            • S sierdzio
              5 Feb 2019, 06:42

              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 6 Feb 2019, 01:03 last edited by
              #6

              @sierdzio Unfortunately, Qt 5.12.1 does not work also.

              1 Reply Last reply
              0
              • Z zosskr
                5 Feb 2019, 15:57

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

                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 6 Feb 2019, 01:54 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
                  5 Feb 2019, 15:57

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

                  J Offline
                  J Offline
                  JonB
                  wrote on 6 Feb 2019, 08:05 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

                  1/8

                  4 Feb 2019, 23:30

                  • Login

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