libqmlbind
libqmlbind copied to clipboard
Documentation & Examples
Hi.
I'm in process of writting vala bindings (WIP), and it would be really helpful to have some examples of the usage/workflow of this library.
Up to now I was trying to learn how to use it by reading the ruby-qml code, but some ruby specific concepts there are not easy to translate.
I've seen similar code from other projects too (like hsqml and qmlrs). It would be great to share efforts into a single C binding.
Thanks!
Known tasks:
- [x] Create API documentation (@florianjacob pull request is here)
- [ ] Port ruby-qml examples
Examples like this could be useful:
/*
Load a single QML file and start the application window.
To compile:
gcc -L /usr/lib -l :libqmlbind.so -o main main.c
*/
#include <qmlbind.h>
int main(int argc, char *argv[]) {
qmlbind_application app = qmlbind_application_new(argc, argv);
qmlbind_engine engine = qmlbind_engine_new();
qmlbind_component component = qmlbind_component_new(engine);
qmlbind_component_load_path(component, "main.qml");
qmlbind_value object = qmlbind_component_create(component);
int exit_code = qmlbind_application_exec(app);
qmlbind_value_release(object);
qmlbind_component_release(component);
qmlbind_engine_release(engine);
qmlbind_application_release(app);
return exit_code;
}
Just extended my example window code with proper exit code returning from your example as well as argc / argv forwarding. Totally forgot that code you posted here! :laughing:
Hey, thanks for your work in this issue!
I think my idea, at that time, was to port at least ruby-qml examples.
Maybe it is easier now with the updated docs :)
I think it's a great idea to collect & port the examples from already-known binding projects. :+1:
Not only because we then have examples helping to understand libqmlbind, but also because the code & concepts can be compared then.
Also, if we have high-quality examples in libqmlbind directly, new bindings can port the examples from C to the new binding language, instead of needing to think on their own.
Let's see how you'll get along with the new documentation, it's a nice test for it if another one writes the examples. :smile_cat:
Collecting the examples directory of more binding projects, for reference:
I think screenshots like in ruby-qml are also a nice addition to see what you'll get as soon as you'll get it to run. The screenshots could also be reused in the actual language binding projects. :wink:
I've made some progress with FizzBuzz example, but I got stuck making method callback work.
The code is here (it needs lots of cleanup).
Thanks in advance!
Signal inputChanged is working as expected.
The original qml file was not modified.
Methods:
quitis called, but I don't know how to call qt app.quit().onInputChanged, which fireson_changed, is not called.
@rainbyte Thanks for implementing examples! Can you create a pull request for the fizzbuzz example? Then we can comment on it.
@seanchas116 , I've made a pull request here