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. Issue with Array.IsArray in Qt6.5
Forum Update on Monday, May 27th 2025

Issue with Array.IsArray in Qt6.5

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 278 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.
  • J Offline
    J Offline
    Johan Borkhuis
    wrote on 12 Dec 2024, 11:27 last edited by
    #1

    I am working on migrating an application from Qt 5.15 to Qt 6.5, but I am running into an issue with Array.IsArray. This works in Qt 5.15, but I always get false as a result in Qt 6.5. The following code is placed in a delegate.

    console.log(Array.isArray(switchbox.switches) + " " + Object.prototype.toString.call(switchbox.switches)) 
    console.log(switchbox.switches.toString() )
    

    This gives the following output in Qt5:

    2024-12-11 14:24:29:374 [tango/qml/runMode/WidgetSwitchbox_01.qml::68] true [object Array]
    2024-12-11 14:24:29:374 [tango/qml/runMode/WidgetSwitchbox_01.qml::70] 2,2,2,2,2,2
    

    But on Qt6.5 I get this:

    2024-12-11 14:22:24:635 [tango/qml/runMode/WidgetSwitchbox_01.qml::67] false [object V4Sequence]
    2024-12-11 14:22:24:635 [tango/qml/runMode/WidgetSwitchbox_01.qml::69] 2,2,2,2,2,2
    

    Has something changed in the functionality of IsArray? And what is a V4Sequence?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kai Nickel
      wrote on 13 Dec 2024, 10:51 last edited by
      #2

      Hello Johan, could you share what switchbox actually is (QML component or C++?) and how its property "switches" is defined?

      1 Reply Last reply
      1
      • J Offline
        J Offline
        Johan Borkhuis
        wrote on 16 Dec 2024, 09:03 last edited by
        #3

        It is quite a way to get to the real data.
        Within the delegate switchbox is defined as:

        property var switchbox: model.modelData
        

        The model is filled in a function inside the listview:

        function filter() {
            var newModel = []
            for (var i = 0; i < switchboxList.length; i++) {
                if (switchboxList[i].enabled) {
                    newModel.push(switchboxList[i])
                }
            }
            model = newModel
        }
        

        switchboxList is recevied from c++:

            property var switchboxList: ipc.iface.switchboxes
        

        And switchboxes is a Q_PROPERTY defined as QList<QObject*>.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          GrecKo
          Qt Champions 2018
          wrote on 16 Dec 2024, 17:37 last edited by
          #4

          The consensus seems to not have to rely on Array.isArray : https://bugreports.qt.io/browse/QTBUG-125289

          1 Reply Last reply
          0

          1/4

          12 Dec 2024, 11:27

          • Login

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