C examples needed
To help facilitate bindings for other languages it would be really helpful to have some c examples that illustrate some of the basic functionality supported by this library. I attempted to create a simple hello world application (https://doc.qt.io/qt-5/qml-tutorial1.html) following your nim example (https://github.com/filcuc/nimqml/blob/3320d7071188c587079e38fd0bb89e938969f044/examples/helloworld/main.nim), but I don't get the window displayed during the exec call.
I can send a pull request with what I have so far if that would be easier to discuss. Thanks in advance for any tips.
Note: compiled and run with gcc 6.1.1 on Arch linux. The qml operates ok when run through qmlscene.
//main.c
include "DOtherSide/DOtherSide.h"
static const char *app = "import QtQuick 2.0\n" "\n" "Rectangle {\n" " id: page\n" " width: 320; height: 480\n" " color: "lightgray"\n" "\n" " Text {\n" " id: helloText\n" " text: "Hello world!"\n" " y: 30\n" " anchors.horizontalCenter: page.horizontalCenter\n" " font.pointSize: 24; font.bold: true\n" " }\n" "}";
int main(int argc, char* argv[]) { dos_qapplication_create(); DosQQmlApplicationEngine *engine = dos_qqmlapplicationengine_create(); dos_qqmlapplicationengine_load_data(engine, app);
dos_qapplication_exec();
dos_qqmlapplicationengine_delete(engine); dos_qapplication_delete();
return 0; }
//Makefile all: hello
hello: main.c gcc -Wall -Werror -I ../../lib/include -L../../build/lib -lDOtherSide main.c -o hello
clean: rm -rf hello
run: hello LD_LIBRARY_PATH=../../build/lib ./hello
@tones111 i could agree that we could add some examples but i would like to focus on the tests suite more (see the test directory), pull requests are wellcome. You did the correct thing by looking at the NimQml examples. Your example doesn't work (even in pure C++) because you forgot to add a Window or ApplicationWindow as the main component. Take a look a the main.qml file in the hello world example of NimQml.
@tones111 As a note keep in mind that your exampe "work" in a qmlscene because it uses under the hood a QQuickView in its implementation and so it implictly create a Windows. This is not compatible with the new QtQuickControls. So when using a QQmlApplicationEngine instead of a QQuickView you should use a Window or ApplicationWindow for spawning a window.