For apps implemented in pure QML, are there any benefits of adding a minimal c++ file and compiling it against libsailfishapp
?
As opposed to not doing that and just launching it through the sailfish-qml
launcher?
The second way has the benefit (for me) of being able to build RPMs noarch
, and testing them through qmlscene
, both of which make developing/testing/tuning on the device much easier.
3 Likes
Iām using sailfish-qml for my apps precisely because it allows me to develop on the SFOS device itself. Not having to rely on a giant SDK is also a big plus.
3 Likes
Check Enable receiving updates with Qt QmlLive
under Projects > Run Settings
inside the IDE and enjoy previewing changes on device just by saving the file under the IDE - no need to re-build/deploy/start. Works with pure QML apps as well as apps based on libsailfishapp, including apps with QMLs bundled in compiled-in resources (qrc).
Find more details in āUsing QmlLive with Sailfish OS Devicesā in the Help inside the IDE and this tutorial QML Live Coding With Qt QmlLive | Sailfish OS Documentation.
4 Likes
Thanks for the tip.
I donāt use the SDK (as Iām swiching computers all the time, not all of which support having the SDK installed,) or even QtCreator most of the time, instead opting for a vim ā git ā docker/obs build ā install RPM workflow. This way all I need on my local machine is a ssh client and sometimes a web browser.
3 Likes
From the source code, this is pretty much all that sailfish-qml
is doing. But just some random thoughts on benefits/drawbacks Iāve experienced personally with apps:
- QML-only apps are likely to be more future-proof than apps with a complied launcher. The fact theyāre noarch as you already pointed out, and that Jolla takes the responsibility for updating
sailfish-qml
if needed (not that this seems to have been needed much) are examples of why this might be the case.
- Sometimes it can be convenient to experiment on the C++ side before moving over to QML. For example I find it easier to debug DBus stuff in C++, even if it ends up in QML. So having a C++ wrapper available can make this kind of experimentation during development easier.
- I find it easier to handle versioning with a C++ launcher, because the version numbers can live in one place (the spec file) and cascade through the app.
There are obviously some cases where C++ may be necessary (e.g. using non-Qt libs) but since you explicitly state the apps can be implemented in pure QML, these wouldnāt apply.
4 Likes
The only reason some of my QML only apps still have C++ involved is that they have localstorage, for instance, which I needed to be able to migrate for stuff like the Sailjail changes to organization, etc.
Some apps I just āinheritedā with libsailfishapp and am looking to move to noarch, pure QML.
Thereās also cases where using c++ would be arguably smarter 
I have this one app where I ā brace yourselves ā do gunzip/deflate in Javascript (which involves a byte-per-byte-copy while doing a char-to-byte conversion, twiceā¦).
3 Likes
Wow. Cool. Thatās a hack and hacks are good! I probably would have been a wimp and done it in python 