Giter VIP home page Giter VIP logo

qtjsonsettings's People

Contributors

b4tman avatar filonenko-mikhail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qtjsonsettings's Issues

Issue with writing QByteArray Data into JSON file using qtjsonsettings

I'm just experimenting with that nice little piece of code (I'm using Qt 5.9 on RedHat Linux 7.x). In principle it works fine but I encountered an issue when attempting to store a QWidget object's geometry and state information into a JSON file. This is what I do in my QMainWindow subclass to store this data in settings:

QtJsonSettings settings;

settings.beginGroup("GUI/MainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
settings.endGroup();

The methods QWidget::saveGeometry() and QWidget::saveState() return a QByteArray. The QtJsonSettings code does not seem to handle this data properly. The resulting JSON file contains for the key "GUI/MainWindow/geometry" some binary data and the value for the key "GUI/MainWindow/state" is 'null' (without the quotes). I'm still a newbee regarding Qt and therefore couldn't find out yet what needs to be changed in the code to correct this issue.
When I use the original QSettings class and the native format (on Linux) then for these keys the data is stored in the form of escaped character sequences. It looks somewhat like this:

geometry=@bytearray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\a\xa4\0\0\0\x43\0\0\xe\x19\0\0\x4\xd3\0\0\a\xa8\0\0\0[\0\0\xe\x15\0\0\x4\xcf\0\0\0\0\0\0\0\0\x11\x35)
state=@bytearray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\0\0\0\x6n\0\0\x4$\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)

It would be great if this behavior could be achieved with the JSON format too.

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.