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. Passing QVariantMap from C++ to QML: Auto conversion fails! Bug??
Forum Updated to NodeBB v4.3 + New Features

Passing QVariantMap from C++ to QML: Auto conversion fails! Bug??

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.6k 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
    jackmack
    wrote on last edited by
    #1

    Hi,

    using Qt 5.4.1 on Windows7 (64bit), VS2010.

    Passing QVariantMap from C++ to QML fails if QMap's key is a big integer! See below example:

    That's the C++ function I call from QML:

    Q_INVOKABLE QVariantMap test() {
    
    	QVariantMap map;
    	QVariantList values;
    	
    	values << "test" << "4294967295" << 5678;
    	map.insert("4800000000", values); // as key I use a big integer as string!
    	
    	return map;
    };
    

    The call from QML:
    ...
    var result = myClass.test()

            for (var key in result)
                console.log(key, JSON.stringify(result[key], 0, 2))
        }
    

    The console output:

    qml: 505032704 [
    "test",
    "4294967295",
    5678
    ]
    But I expect 4800000000.

    The key in C++ is a QString("4800000000") which is converted automatically my QQuick into an integer 505032704. BAD!!!

    But if I use QString("4700000000") as key it works! Seems there is a conversion bug/limit when QQuick converts string number into int (uint?).

    Any experience, suggestions to fix?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From a quick look, I wonder if you are not hitting this ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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