简体   繁体   中英

QML map binding v2

I'm complete noob in Qt, so my question may sound too stupid, but I really need help. I know C++ a little and that's it.

So, my task is to write a C++ program which reads INI-alike (format is not very important) file

height=20
width=15

To make it clear, I have no idea what properties will be defined in this file, names or types are unknown to me at compile time.

After that program loads QML file (I can do this) and injects loaded file data (have no idea how to do this) as JavaScript object, for instance named "Settings", so that QML property bindings will use it like

Rectangle {
   width: Settings.width
   height: Settings.height
}

So the question is: How can I inject read data as JavaScript object into QML so that QML property binding will use it?

One way to do it would be to write a QObject wrapper around QSettings and expose an instance of it to QML, another would be to use the Settings QML Type . I am sure there are others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM