Git Product home page Git Product logo

Comments (2)

Skycoder42 avatar Skycoder42 commented on July 20, 2024

Not supported yet, but thanks to the change of 3.0, easy to implement.

Have a look at:

You can simply copy those files and replace QList with QVector in all the methods. It can be added to an instance using QJsonSerializer::addJsonTypeConverter

I will keep this issue open, and will add it in the next version.

from qtjsonserializer.

Skycoder42 avatar Skycoder42 commented on July 20, 2024

One one thing: In Order for that to actually work, you need to register converters from QVector<T> to QVariantList and back. Sadly, this must be done for every type T. Thats one of the reasons I only support QList for now. I register those converters for many standard Qt types, but doing that for any container would generate way to many symbols.

I decided to use QList, as of my knowledge, even in Qt5, this is the default container (It is primarily used by Qt classes, and stated as the "default" in here: https://doc.qt.io/qt-5/containers.html).

So most likely, I will not add QVector to the library. You can either create it yourself, as state before, or use the following workaround:

struct MyGadget {
    Q_GADGET

    Q_PROPERTY(QList<int> myInt READ getMyInt WRITE setMyInt)
    Q_PROPERTY(QVector<int> myInternalInt MEMBER _myInt STORED false) //will not be serialized

public:
    QVector<int> _myInt;

private:
    QList<int> getMyInt() const {
        return _myInt.toList();
    }
    void setMyInt(const QList<int> &list) {
        _myInt = QVector<int>::fromList(list);
    }
};

from qtjsonserializer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.