Start developing for Sailfish OS
Sailfish OS is a mobile platform based on Linux kernel. Read about it on official website or in one of the reviews platform on the network. For example, one of them was published on GeekTimes. In this article I would like to touch on the process of developing applications for Sailfish OS, to talk about how to start to program under this platform and also share some features of the development.
To write applications for the platform Sailfish OS uses the C++ language and Qt libraries, as well as the QML language to describe GUI applications. So if you already have experience writing apps using Qt and QML, developing for Sailfish OS will not cause you trouble. In addition, Sailfish OS allows you to develop native applications in Python. However, this topic is beyond the scope of this article and will not be described in it (more about this can be read, for example, here).
As for other mobile platforms, developing for Sailfish OS is using SDKs provided by the creators of the platform. SailfishOS SDK includes:
the
Mer Build Engine and the emulator platform is delivered as virtual machine images for VirtualBox. However, VirtualBox itself is part of SailfishOS SDK is not included. Therefore, before actually installing the SDK, you must first install the VirtualBox version than 4.1.18. In addition, if you are running Windows, before install SDK, must install the Windows package Microsoft Visual C++ 2010 redistributable (x86).
He SailfishOS SDK available for Linux, Windows and Max OS X, it can be download here. The SDK comes in the form of a graphical installer, so installing the SDK should not be a problem. However, during the installation you will be asked an alternative path for projects. This parameter is required in order for a virtual machine with Mer Build Engine had access to the source code of your project. The default is your home directory. Subsequently, the setting can be changed in the settings of Qt Creator.
After installing the SDK you should be ready to develop applications for the platform Sailfish OS.
Creating Hello World! the application also does not cause any difficulties. Just run Qt Creator, click on the "New project" on the main screen (or through menu File -> new file or project...) and a custom project:
The auto-generated project a bit more complicated than the standard one-page Hello World. It allows to reveal some features of Sailfish OS. The main page displays a standard greeting. However, if on this screen to perform a gesture swipe down (default controls for this platform) at the top, a menu will appear allowing you to navigate to the second page of the application where a list of elements.
Here are some screenshots of Hello World application:
the
Now let's look at the code. Everything is standard for QML applications, and therefore familiar to anyone who ever wrote applications using this language. The only .cpp file describes what .qml should be displayed when the application starts. In our case it is HelloWorld.qml. In addition, the project contains 2 pages and Cover Page that defines the appearance of the application on the home screen of Sailfish OS, which displays thumbnails of all running apps and allows to switch between them or close them.
HelloWorld.qml describes the application's main window. It indicates the starting page of the application and Cover Page, and additional settings for the application (in our case, it allowed screen orientation and screen orientation, which will be used by default):
the
FirstPage.qml describes the start page of the application. Everything is standard for QML apps, but there are some feature of Sailfish OS on which you should pay attention:
the
Here we use the element SilicaFlickable, which, first, allows to make the content inside the scrollable element, in case he is not fully fit inside the element. And secondly, allows the use of PullDownMenu — the application menu is opened by swiping down.
In addition, I would like to pay attention to CoverPage.qml, which describes the Cover Page of the application. It contains the following elements:
the
This element allows in addition to displaying information to provide the user the ability to control the app directly from the thumbnails on the home screen.
To run the application in emulator you need the side menu to choose the set for i486, you need a build type (release or debug) and installation method Deploy as RPM Package:

Then simply click on the green arrow in the sidebar. This action will collect the application starts the emulator, installs and launches your app on the emulator.
Furthermore, you can just start the emulator by clicking on the button
from the side menu. This will allow you to just explore Sailfish OS without having the device on the platform.
That's all, in the future I will try to explain some features of development under the platform Sailfish OS.
Author: Laura Dennis
UPD: a Big thank you to @kirikch for remarks and comments, they were addressed in the updated text.
Article based on information from habrahabr.ru
To write applications for the platform Sailfish OS uses the C++ language and Qt libraries, as well as the QML language to describe GUI applications. So if you already have experience writing apps using Qt and QML, developing for Sailfish OS will not cause you trouble. In addition, Sailfish OS allows you to develop native applications in Python. However, this topic is beyond the scope of this article and will not be described in it (more about this can be read, for example, here).
As for other mobile platforms, developing for Sailfish OS is using SDKs provided by the creators of the platform. SailfishOS SDK includes:
the
-
the
- QtCreator — IDE, which actually is proposed to conduct the entire development process. the
- Mer Build Engine, which is necessary for building applications.
- Examples, tutorials, and documentation to the API.
the Sailfish OS Emulator. the
Mer Build Engine and the emulator platform is delivered as virtual machine images for VirtualBox. However, VirtualBox itself is part of SailfishOS SDK is not included. Therefore, before actually installing the SDK, you must first install the VirtualBox version than 4.1.18. In addition, if you are running Windows, before install SDK, must install the Windows package Microsoft Visual C++ 2010 redistributable (x86).
He SailfishOS SDK available for Linux, Windows and Max OS X, it can be download here. The SDK comes in the form of a graphical installer, so installing the SDK should not be a problem. However, during the installation you will be asked an alternative path for projects. This parameter is required in order for a virtual machine with Mer Build Engine had access to the source code of your project. The default is your home directory. Subsequently, the setting can be changed in the settings of Qt Creator.
After installing the SDK you should be ready to develop applications for the platform Sailfish OS.
Creating Hello World! the application also does not cause any difficulties. Just run Qt Creator, click on the "New project" on the main screen (or through menu File -> new file or project...) and a custom project:
-
the
- is selected as application type SailfishOS Qt Quick Application:
the - Specify the name and directory in which to save project data (remember that the project should be saved only in your home directory or an alternative way for projects specified during installation or in the settings of Qt Creator, because to build the project Mer Build Engine needs to have access to it):
the - Select the correct kits that will be used to build the application.
All, as you can see from the screenshot above, there are two sets:
the-
the
- MerSDK-SailfishOS-armv7hl for devices based on ARM architecture (for example, Jolla),
the - MerSDK-SailfishOS-i486 — for devices based on Intel architecture.
Here it is also worth noting that the emulator only works with a set of i486. Therefore, if you plan to test your app in the emulator, choose in this step you need the second set.
the - MerSDK-SailfishOS-armv7hl for devices based on ARM architecture (for example, Jolla),
- Specify additional information about the project:
the - And all the SDK generated us Hello World project.
The auto-generated project a bit more complicated than the standard one-page Hello World. It allows to reveal some features of Sailfish OS. The main page displays a standard greeting. However, if on this screen to perform a gesture swipe down (default controls for this platform) at the top, a menu will appear allowing you to navigate to the second page of the application where a list of elements.
Here are some screenshots of Hello World application:
![]() |
![]() |
![]() |
Now let's look at the code. Everything is standard for QML applications, and therefore familiar to anyone who ever wrote applications using this language. The only .cpp file describes what .qml should be displayed when the application starts. In our case it is HelloWorld.qml. In addition, the project contains 2 pages and Cover Page that defines the appearance of the application on the home screen of Sailfish OS, which displays thumbnails of all running apps and allows to switch between them or close them.
HelloWorld.qml describes the application's main window. It indicates the starting page of the application and Cover Page, and additional settings for the application (in our case, it allowed screen orientation and screen orientation, which will be used by default):
the
ApplicationWindow
{
initialPage: Component { FirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: Orientation.All
_defaultPageOrientations: Orientation.All
}
FirstPage.qml describes the start page of the application. Everything is standard for QML apps, but there are some feature of Sailfish OS on which you should pay attention:
the
//...
SilicaFlickable {
anchors.fill: parent
PullDownMenu {
MenuItem {
text: qsTr("Show second page")
onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
}
}
//...
Here we use the element SilicaFlickable, which, first, allows to make the content inside the scrollable element, in case he is not fully fit inside the element. And secondly, allows the use of PullDownMenu — the application menu is opened by swiping down.
In addition, I would like to pay attention to CoverPage.qml, which describes the Cover Page of the application. It contains the following elements:
the
CoverActionList {
id: coverAction
CoverAction {
iconSource: "image://theme/icon-cover-next"
}
CoverAction {
iconSource: "image://theme/icon-cover-pause"
}
}
This element allows in addition to displaying information to provide the user the ability to control the app directly from the thumbnails on the home screen.
To run the application in emulator you need the side menu to choose the set for i486, you need a build type (release or debug) and installation method Deploy as RPM Package:

Then simply click on the green arrow in the sidebar. This action will collect the application starts the emulator, installs and launches your app on the emulator.
Furthermore, you can just start the emulator by clicking on the button

That's all, in the future I will try to explain some features of development under the platform Sailfish OS.
Author: Laura Dennis
UPD: a Big thank you to @kirikch for remarks and comments, they were addressed in the updated text.
Комментарии
Отправить комментарий