We have moved to a new Sailfish OS Forum. Please start new discussions there.
7

How to deploy Qt/QML application without SDK?

asked 2014-10-15 20:55:41 +0300

charlycoste gravatar image

updated 2014-10-15 20:57:24 +0300

I already had a try with coding some small applications with Qt/QML on Ubuntu with the packaged QtCreator or with the official installer

By the way, I can imagine that using Silica components or using SailfishOS API in a software can't be done without using the SDK. But what if we are just using basic QtQuick components?

Do we really need to install an other QtCreator for each platform we want to deploy on, or is there something to do in a "vanilla" QtCreator to make it deploy on a Jolla phone ?

Thank you for any answer...

edit retag flag offensive close delete

Comments

You need to cross compile for ARM, and you need the same environment (packages etc.) that are installed on the phone. Using a VM for this is really a no-brainer, so I don't really get your point. If it's only QML, you can probably "deploy" directly (make an RPM package), though you won't be able to test without the Silica components.

dthierbach ( 2014-10-15 22:37:09 +0300 )edit

MartinK, could you click on "convert to answer" so I could vote for it ? :)

charlycoste ( 2014-10-19 20:38:08 +0300 )edit

@charlycoste: Sure! :)

MartinK ( 2014-10-19 23:28:57 +0300 )edit

5 Answers

Sort by » oldest newest most voted
12

answered 2014-10-16 03:10:50 +0300

MartinK gravatar image

updated 2014-11-28 00:18:06 +0300

I'm using PyOtherSide for modRana, so my application is just Python & QML. As I don't have to compile anything, I just rsync the source files to the Jolla and start the application with qmlscene.

Haven't used the SDK in ages as I don't need it at all. :)

As for debugging the application on desktop - I'm using Universal Components, which support dynamic backend switching (Silica/QtQuick Controls) so I can run the same modRana source code on my desktop and on my Jolla and it always looks native. :)

Update - where to get qmlscene ?

The qmlscene utility is not installed by default, but can be easily acquired by installing the qtchooser and qt5-qtdeclarative-qmlscene packages:

pkcon install qtchooser qt5-qtdeclarative-qmlscene

or (as root):

zypper install qtchooser qt5-qtdeclarative-qmlscene
edit flag offensive delete publish link more

Comments

I've been wishing for something like Universal Components and didn't know it exists, thank you for mentioning it!

Camil B ( 2014-10-23 21:35:49 +0300 )edit

@Camil B Thanks! It demonstrates the concept works and while it is still incomplete, it can be improved thanks to being open source. :)

MartinK ( 2014-10-23 22:39:29 +0300 )edit

That is so great. I always found Sailfish development to be cumbersome (no offence to Jolla) with two VMs (or one vm + phone). It seems now apps can be continuously developed (similar to web apps) on your desktop and only tested on Sailfish VM/device. @MartinK would you mind giving us some minimal-viable example of a QML app with Python (and PyOtherSide) that executes on desktop and the device alike? I think this kind of "reference template" for an app would really beneficial to the community. Usually everyone invents their own project structure etc. and it's better to use good patterns.

Michal ( 2015-04-18 12:08:11 +0300 )edit

@MartinK I noticed current modrana doesn't seem to use qmlscene anymore, is qmlscene banned from harbour that caused it?

szopin ( 2019-11-01 20:19:11 +0300 )edit
1

@szopin Nope - I don't think qmlscene was actually ever allowed for Harbour compatible apps & developers are supposed to be using the sailfish-qml utility:

https://harbour.jolla.com/faq#.desktop-Files

But the utility is actually pretty limmited and overall horrendous for what modRana needs (partially due to being multi platform) so I've decided to write a native launcher for it. What the native launcher does & some background for the change can be read here:

https://github.com/M4rtinK/modrana/commit/de346537eda664d15da3941d186439c8e06d71c2#diff-d266491a492b352f7a6b4d56e612bc7d

https://github.com/M4rtinK/modrana/blob/master/run/launcher/README.rst

MartinK ( 2019-11-02 00:32:08 +0300 )edit
2

answered 2014-10-23 21:34:15 +0300

Camil B gravatar image

updated 2014-10-23 21:41:18 +0300

Warning: by following this tutorial you will drill a hole in the root filesystem, which is a security issue. Just so you know.

Here's how I do the programming (just learning QML at the moment, so I needed a procedure for very quick prototyping without the SDK). This is an example for a hypothetical application, called Oranges. We will put its pure-QML code in a nicely accessible place, and then call it in the command-line. So here it is:

Create folder /home/nemo/Devel. This folder will hold all your pure-QML projects. Inside /home/nemo/Devel, create a folder Oranges, to hold your project. Then create the following folders:

/home/nemo/Devel/Oranges/qml
/home/nemo/Devel/Oranges/qml/pages
/home/nemo/Devel/Oranges/qml/cover

Inside /home/nemo/Devel/Oranges/qml, put the file Oranges.qml. This is the main file of your application, and must have the same name as your application - it's a rule in SailfishOS (maybe MeeGo too?). Inside Oranges.qml, copy this:

import QtQuick 2.0
import Sailfish.Silica 1.0
import "pages"

ApplicationWindow
{
  initialPage: Component { MyFirstPage { } }
  cover: Qt.resolvedUrl("cover/CoverPage.qml")
}

Of course, this is the standard ApplicationWindow definition, like in any SailfishOS app. It's all you need. Don't forget to also create the QML files /home/nemo/Devel/Oranges/qml/pages/MyFirstPage.qml, and /home/nemo/Devel/Oranges/qml/cover/CoverPage.qml, and put nice things in them to impress your users.

Now the best parts:

  1. Open the terminal, and go root.
  2. ln -s /home/nemo/Devel/Oranges /usr/share/Oranges (you will do this for every project you put into your Devel folder. This is a security hole, since any app can maliciously overwrite your files in /home/nemo/Devel/Oranges with bad QML code, and that code will be executed by SailfishOS without discrimination)
  3. Ctrl-D to exit root.
  4. Now the fruity magic: sailfish-qml Oranges and your app starts! Or crashes when it has bugs, and QML will log everything to the terminal, of course.

What you achieved is this: now you have the project easily editable in your home and you can run it in the proper sailfishy way. sailfish-qml will run your QML files as if they were a real app, respecting all conventions and giving you all the privileges that a full C++ SailfishOS app would have. Well, at least all that's available through the QML API. Moreover, your source is on your phone all the time, so you can edit it easily. If you have Linux + KDE, you can transparently access the phone's filesystem through SFTP (did you know that it supports SFTP, and it's enabled by default? it's awesome! :D) like it would be mounted as a partition, thanks to KDE's awesome KIO framework. So you edit the files directly on the phone, live, with your favourite editor.

If someone could give some instructions about how to create a custom Launcher icon for Oranges, that would be awesome.

Keep the dry side up and the wet side down!

edit flag offensive delete publish link more

Comments

Launchers are created with a Oranges.desktop file located in /user/share/applications. They are text file following the Freedesktop specification. They contain the name of the application (in several languages if provided), the way to run it, an icon... For instance :

[Desktop Entry]

Type=Application

X-Nemo-Application-Type=silica-qt5

Name=Oranges

Icon=Oranges

Exec=sailfish-qml Oranges

And an icon should be placed in /usr/share/icons/hicolor/86x86/apps/Oranges.png being of a size 86x86 pixels.

Damien Caliste ( 2014-11-27 23:33:09 +0300 )edit

Does this guide still applies with Vaarainjarvi?

piero ( 2015-01-14 04:09:21 +0300 )edit
2

answered 2014-10-23 22:08:30 +0300

MartinK gravatar image

updated 2014-10-23 22:09:50 +0300

Why no just run the application with qmlscene ? Unlike the very limited sailfish-qml launcher it can launch a QML applications from any path:

qmlscene /home/nemo/whatewer/app.qml

I'm not sure if qmlscene is included by default, but rpm -qf /usr/bin/qmlscene tells me it is provided by the qtchooser package.

edit flag offensive delete publish link more

Comments

2

I noticed sailfish-qml being used by Python-based apps, like gPodder, I think. If anyone could point out the difference between qmlscene and sailfish-qml, it would be great. Maybe qmlscene doesn't support the active cover with actions? Or maybe Harbour compatibility? There must be a reason for sailfish-qml to exist. What other limitations of it do you know of? Though maybe qmlscene should be preferred, if it can run from anywere.

Camil B ( 2014-10-23 22:27:57 +0300 )edit
1

@Camil B Yeah, I also use sailfish-qml in my desktop file, but during development I use the more full featured qmlscene. As for the differences, I only know sailfish-qml is based on libsailfishapp and might use something called booster for faster startup. It would be indeed interesting if someone more versed in sailfish-qml internals stepped in and pointed out the differences from qmlscene. BTW, I've recently opened a couple of bugs/RFEs on sailfish-qml on Github:

[bug] --help and --version options are interpretted as input

[RFE] add support for appending to QML import path to sailfish-qml

[RFE] support for passing arguments to applications in sailfish-qml

MartinK ( 2014-10-23 22:36:25 +0300 )edit

According to the Harbour FAQ, the .desktop file should use sailfish-qml. But it doesn't say why... Anyway, I'm giving up on it during prototyping - qmlscene looks like a better option when you just do the coding. Production stuff should stick to sailfish-qml, because Jolla says so and we don't know enough to argue :)

Camil B ( 2014-10-23 22:40:39 +0300 )edit
2

qmlscene doesn't seem to allow Cover Actions. The cover of a QML app launched with qmlscene is just black, with the text My Cover, but no actions. Also, when closing the app, it exits with segmentation fault.

Camil B ( 2014-11-01 10:55:57 +0300 )edit
1

answered 2014-10-23 10:59:34 +0300

charlycoste gravatar image

updated 2014-10-23 11:03:43 +0300

I discovered something interesting thanks to an other question : https://together.jolla.com/question/58459/source-code-of-calender-app/#post-id-58470.

When we install an application, QML code goes to /usr/share/[application_name]. So, at least, we can deploy once the application with the SDK, then edit QML files (need to be root, so type: devel-su and use the same password as nemo)

But that's a solution only for QML edition. Cannot be used to edit C++ code, but at least, we can use every installed QML components.

edit flag offensive delete publish link more
1

answered 2015-04-07 04:19:02 +0300

backpackjoe gravatar image

I have written a small Makefile and a template that packages/deploys a qml/pyOtherSide app:

https://github.com/dasimmet/Sailfish-Python

It uses fpm to build a rpm package in /tmp/fpm-jolla and sends it to your jolla/emulator via ssh, where it is installed with pkcon. I still have to look into what it takes to make them harbour-conform, but for development purposes, it works quite nicely.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
13 followers

Stats

Asked: 2014-10-15 20:55:41 +0300

Seen: 3,448 times

Last updated: Apr 07 '15