[SailfishDevel] Is it worth it to use the Sailfish namespace functions/functions defined in sailfishapplicatoin.cpp instead of creating a QML/QtQuick application the default way?
christopher.lamb at thurweb.ch
christopher.lamb at thurweb.ch
Sat May 4 19:41:36 UTC 2013
Hi Superpelican
When programming Qt, you can mix and match QML, C++, and Javascript
freely, using whichever of these that is best for the particular task
you have in mind. I don't think SailfishOS changes this in any way.
With your questions in mind, I ran through my major app which is
mainly QML, but with some C++ and Javascript thrown in for good luck.
It is still largely a Harmattan app, but that is directly comparable
to Sailfish in the context of your question.
I used Javascript for Database access via SQLite; as well as lots of
inline javascript with my QML files.
I used C++ where I could not find a way (or an elegant way) to do
something in QML. I actually have two "plugins". One allows me to
control the LED flash (as an emergency flash), the other gives me SMS
functionality. Each of these has its own class.
These are both registered in the main.cpp by qmlRegisterType, which
Thomas P points out "is another way of doing things".
Harmattan has a qmlapplicationviewer.cpp, which seems to be a direct
equivalent of the sailfishapplication.cpp. Interestingly the
qmlapplicationviewer is headed with a comment advising not to change it.
My use case is a little different from yours. In my case the main
control is from QML, with C++ / javascript providing helper
functionality (flash the led, send an SMS, persist settings to DB etc.)
Chris
Zitat von superpelican <superpelican at zoho.com>:
>
> Are there any big benefits to using the functions/classes defined in
> sailfishapplication.cpp compared to just creating a "normal" QML
> application (by just creating a QDeclarativeView object etc.). Does
> doing it the Sailfish specific way give you a performance
> optimization advantage? When reading through sailfishapplication.cpp
> I find things like a #ifdef statement that calls a
> qDeclarativeView() function which is in a special MDeclarativeCache
> namespace, is this for example a special, optimized function? I also
> see that QGLWidget is #included, does doing it the Sailfish specific
> way give you a openGL accelerated QML UI on Sailfish?
>
> The Sailfish specific way complicates things, especially writing a
> hybrid C++/QML app. I'm still quite new to programming and Qt/QML
> especially and I'm already having a hard time figuring out how to
> let QML/C++ communicate with each other. Luckily there is lots of
> documentation about it, but there isn't any Sailfish specific
> documentation about writing a QML/C++ hybrid app.
>
>
> Thanks in advance,
>
>
> Superpelican :)
>
>
> P.S.: Thomas Perl thanks a lot for your help and the handy webpages. ;)
>
>
More information about the Devel
mailing list