Important: Please read the Qt Code of Conduct -

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

  • 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 [
    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?

  • Lifetime Qt Champion


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

Log in to reply