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
Qt 6.11 is out! See what's new in the release blog

Issue with Array.IsArray in Qt6.5

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.1k Views 1 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.
  • J Offline
    J Offline
    Johan Borkhuis
    wrote on 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 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 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
        • GrecKoG Offline
          GrecKoG Offline
          GrecKo
          Qt Champions 2018
          wrote on 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

          • Login

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