b4tman / qtjsonsettings Goto Github PK
View Code? Open in Web Editor NEWClass for storing Qt5 Application settings into JSON file. (fork from http://gitorious.org/qtjsonsettings)
Class for storing Qt5 Application settings into JSON file. (fork from http://gitorious.org/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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.