QML Design, required C++ logic?
-
Is it possible to make all logic in QML or do I have restrictions against C++ code?
I want to make a alarm buzzer for my Raspberry Pi - for this I need some logic in setting up an alarm (cron job), set different MP3 files for playing and do some other stuff (sleep, etc.).
My question that makes me crazy right now is:
Can I do all in QML (Design and Logic) or do I have to use C++ additionally?
If C++ is needed is there a tutorial how to bind C++ method slots to QML signals?
Thx!
-
I dont' think you'll manage to set up a cron job from within QML, but other tasks are doable there easily.
Here is a part of the documentation for connecting C++ and QML: "link":http://qt-project.org/doc/qt-5/qtqml-cppintegration-topic.html.
-
Hmm, another way can be to write a nice little nodejs server that listen to a specific port. With qml and JavaScript you can send request to this server with the needed data. Be careful normally for create cron jobs you need root rights it doesn't madder if c++ or nodejs or whatever.
-
You might wrap you qml app into a shell script. Pipe the input of a crontab file to your app and pipe the output back to the crontab file and call crontab, e.g.:
@
cat MyCrontab.txt | xargs myQmlAlaramApp > MyCrontab.txt
crontab MyCrontab.txt
@
Inside qml access the argument string via:
@
Text {
text: Qt.application.arguments[1]
@