Parse QML to QVariant?



  • Hi all,
    I have a number of quite complicated QVariant structures. Like this:

    QVariantMap booster1;
    booster1["power"] = 10;
    booster1["dir"] = 45;
    QVariantMap booster2;
    booster2["power"] = 10;
    booster2["dir"] = -45;

    QVariantList boosters;
    boosters.push_back(booster1);
    boosters.push_back(booster2);
    QVariantMap spaceship;
    spaceship["boosters"] = boosters;

    (This is just an example).

    I am getting really confused because I have to define everything backwards.

    Instead I would like to write it in QML syntax:

    spaceship : {
    boosters : [
    { power : 10,
    dir : 45
    },
    { power : 10,
    dir : -45
    }
    ]
    }

    Is there a parser or something that takes QML as input and returns me a QVariant?
    Any tips on writing one?
    I think this is a quite useful feature


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.