Qt-Creator-with-BlackBerry-10: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Redirected page to Qt Creator with BlackBerry 10)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:BlackBerry]]<br />[[Category:HowTo]]
#REDIRECT [[Qt_Creator_with_BlackBerry_10]]
 
[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]
 
= Using Qt Creator for BlackBerry 10 Development =
 
== Overview ==
 
Qt is one of the application development frameworks available on the BlackBerry 10 platform. Using Qt, you can deploy your Qt C++ or Qt Quick application to BlackBerry 10 devices. The current release of the &quot;BlackBerry 10 Gold NDK&amp;quot;:http://developer.blackberry.com/native/download/ includes Qt 4.8 for both the simulator target (x86) and device targets (arm) available for development. Compared to the development for the PlayBook, Qt is integrated in the BlackBerry 10 device firmware and so can be used by Qt applications as shared libraries.
 
This page explains how to use QtCreator 3.0 with the &quot;BlackBerry 10 NDK&amp;quot;:http://developer.blackberry.com/native
 
'''''Note:''''' The NDK is in continuous development. We will update this page from time to time to cover new releases of the NDK and QtCreator. The following steps were tested using Ubuntu 12.04 LTS 32-bit but should work in a similar way on Windows and Mac OS X.
 
'''''Note:''''' If you are using Qt Creator 3.2, you won't be able to run and debug your application on the device. This is an known issue that will be fixed in the next releases.
 
== Getting Started ==
 
The following tools are required for development for the BlackBerry 10 platform using QtCreator:<br />* Momentics IDE<br />* BlackBerry 10 API Level<br />* QtCreator 3.0<br />* BlackBerry 10 device or simulator
 
See complete article [[Setup for BlackBerry10 development]]
 
== QtCreator 3.0 ==
 
QtCreator 3.0 can be downloaded:
 
* from &quot;Official Downloads&amp;quot;:http://qt.io/download#qt-creator
* from &quot;Official Development Releases Downloads&amp;quot;:http://download.qt.io/development_releases/qt/5.2/
* from &quot;Daily Snapshot Builds of QtCreator&amp;quot;:http://download.qt.io/snapshots/qtcreator/
* cloned and built from &quot;QtCreator Source Code&amp;quot;:http://qt.gitorious.org/qt-creator
 
'''''Note:''''' QtCreator 3.0 Beta identifies itself as QtCreator 2.8.82 (pre-3.0.0).
 
'''''Note:''''' BlackBerry 10 support in QtCreator 3.0 is provided by &quot;Qnx&amp;quot; plugin. This plugin should be enabled by default.
 
== Configuring QtCreator ==
 
QtCreator 3.0 brings new features for BlackBerry 10 support that enables you to easily create, build, deploy, run and debug your application directly from the IDE.
 
Here are new features that BlackBerry 10 plugin provides in QtCreator 3.0:
 
* Support for using multiple BB NDK API Levels
* Automatic detection of installed BB NDK API Levels
* Improved Device wizard
* Updated BlackBerry Signing Keys options page, creation of Developer Certificate and Debug Token
* Easy setup of your BlackBerry 10 development environment (Kits, Qt Version, Compiler, …)
* UI editor for bar-descriptor.xml files
 
=== Configuring API Level ===
 
QtCreator 3.0 has built-in automatic detection of installed BlackBerry 10 API Levels. You can look open &quot;Tools <s>&gt; Options…</s>&gt; BlackBerry <s>&gt; NDK&amp;quot; page (on MacOSX: &quot;Preferences</s>&gt; BlackBerry <s>&gt; NDK&amp;quot;) to see the listing.
<br />[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-BlackBerry-NDK.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-BlackBerry-NDK.png]]
<br />If your API Level is not listed under 'Auto-Detected' category, you can add it by clicking on &quot;Add&amp;quot; button and browsing for the &quot;bbndk-env.sh/bat&amp;quot; that represent your API Level.
<br />For each API Level listed in the &quot;BlackBerry</s>&gt; NDK&amp;quot; options page, there are the following settings pre-configured:
 
* one QtVersion for HOST/OS/ARCH/usr/bin/qmake - represents Qt4 qmake
* one Kit for Qt4 on Device
* one Kit for Qt4 on Simulator
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-Build-Run-Kits-Device.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-Build-Run-Kits-Device.png]]
 
Qt5 is not available built-in on 10.2 device firmware. When available, additional QtVersion and two Kits are going to be created for that Qt5 too.
 
'''''Note:''''' If you are having many API Levels installed but not using them you can selected appropriate API Level in the listing and press &quot;Deactivate&amp;quot; button. Then related QtVersions and Kits are removed. All ''Active'' API Levels are display with bold font in the listing.
 
=== Configuring Signing Keys ===
 
'''''Note:''''' Make sure that you have BlackBerry 10 API Level version 10.2 or newer installed on your host machine. This is a prerequisite for proper work of Signing Keys configuration. See &quot;BlackBerry 10 API Level&amp;quot; section for information how to install it.
 
Open &quot;Tools <s>&gt; Options…</s>&gt; BlackBerry <s>&gt; Keys&amp;quot; page (on MacOSX: &quot;Preferences</s>&gt; BlackBerry <s>&gt; Keys&amp;quot;) to configure keys. It should state, that you have have your keys ready to be used.
<br />[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-BlackBerry-Keys.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-BlackBerry-Keys.png]]
<br />'''''Note:''''' if it prints &quot;No keys found.&quot; message when you need to obtain BlackBerry Signing Keys as described above.
<br />Click on &quot;Create certificate&amp;quot; button to create one. Fill your Author (any name) and password and press OK button. Now your &quot;Keys&amp;quot; page should display details about your &quot;Developer Certificate&amp;quot;.
<br />h3. Configuring Qt Creator for the Qt5 Overlay
<br />When installing the Qt5 Overlay, Qt Creator might not be aware of any changes and won't immediately generate kits for the Overlay Qt5 version. That's because Qt Creator (version 3.0 and higher) should have detected the installed API Levels, and generated kits for the active API level. In order to force Qt Creator to generate the new kits for Qt5 Overlay version, you need to deactivate and activate the &quot;BlackBerry Native SDK 10.2&amp;quot; API level again after you have installed the Overlay.
<br />If you only have one unique &quot;BlackBerry Native SDK 10.2&amp;quot; API Level, you won't be able to deactivate it with Qt Creator 3.0, since it needs to keep at least one API level activated for other features that depend on it. To work around this, you need to install a new API Level (i.e target) and activate it, before you are able to deactivate/activate the &quot;BlackBerry Native SDK 10.2&amp;quot; API Level.
<br />Due to a known Qt mkspec issue in QtCreator 3.0 , please make to use a correct Qt mkspec when building your project, as described in the next section.
<br />'''''Note:''''': The upcoming Qt Creator 3.1 doesn't require any API level to be active, and should provide new button to refresh your existing API levels to detect any new changes.
<br />h3. Mkspec known issue:
<br />Due to some changes in the Qt mkspec targeting armlev7 architrecture, QtCreator 3.0 will use a wrong mkspec when building your project. In order to workaround this, you need to explicitly set the mkspec in your BlackBerry Kits targeting the device as follow:
<br />* For BlackBerry kits using Qt5 version: blackberry-armle-v7-qcc<br />* For BlackBerry kits using Qt4 version: blackberry-armv7le-qcc
<br />The Qt mkspec entry for the generated kits that are targeting the simulator should be always set to &quot;blackberry-x86-qcc&amp;quot; regardless which Qt version is used.
<br />'''''Note:''''': This issue should be fixed in the upcomming QtCreator 3.1 release.
<br />h3. Adding Device or Simulator
<br />Go to &quot;Tools</s>&gt; Options <s>&gt; Devices</s>&gt; Add <s>&gt; Blackberry Device&amp;quot; (on Mac: &quot;Preferences</s>&gt; Devices <s>&gt; Add</s>&gt; Blackberry Device&amp;quot;) to add a BlackBerry Device. It opens a BlackBerry Device wizard that allows to add either a physical device or a simulator.
 
* On the first page, select an auto-detected device and enter device password. If device is not auto-detected, choose &quot;Specify Manually&amp;quot; item and enter IP address too. Device password is required for connecting to physical devices only
* On the second page, the device is query and SSH connection keys are generated (stored at &quot;~/.config/QtProject/qtcreator/qnx/id_rsa&amp;quot; file)
* On the third page, you can specify the configuration name and debug-token (locate an existing one or click on &quot;Generate&amp;quot; button to generate new one) - see the next section for more information.
 
'''''Note:''''' Press &quot;Apply&amp;quot; in the &quot;Options&amp;quot; dialog to store the changes otherwise the other Options pages will not notice your new device.
 
=== Connecting to Device ===
 
QtCreator automatically tries to connect to a device when:<br />* Run an application with BlackBerry kit<br />* Press &quot;Apply&amp;quot; button in the &quot;Options&amp;quot; dialog to store newly added device
 
When a device is connected, QtCreator starts working with the device e.g. running a project.
 
==== Troubleshooting ====
 
If you see the following line in the connection log:<br /><code><br />Info: Connecting to target 169.254.0.1:4455<br />Error: Connection failed: connect timed out<br /></code><br />then it means that QtCreator cannot connect to a device.
 
Check if the device:<br />* is switched to Development Mode<br />* has correct platform set for &quot;Settings <s>&gt; Storage</s>&gt; Usb connection&amp;quot;. Use &quot;Connect to Windows&amp;quot; for Linux.<br />* is NOT connected by any &quot;blackberry-connect&amp;quot; command-line tool already.<br />* is NOT connected already in Momentics IDE.
 
If the device was connected by &quot;blackberry-connect&amp;quot; or Momentics IDE then:<br />* stop the tool<br />* unplug the device from USB<br />* wait for 15 seconds<br />* plugin the device to USB<br />* Connect to the device from QtCreator
 
For details, see &quot;issue QTCREATOR-10910&amp;quot;:https://bugreports.qt.io/browse/QTCREATORBUG-10910 .
 
=== Generate and Upload Debug Token ===
 
To be able to deploy an application to your physical device, you need to have a valid Debug Token on your physical device and use the same Debug Token for creating your BlackBerry aplication.
 
When you are adding a new BlackBerry 10 device to QtCreator you need to:<br />* specify an existing file with a debug token generated for your device<br />* generate a new debug token for your device
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Add-BlackBerry-Device-Configuration.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Add-BlackBerry-Device-Configuration.png]]
 
Similarly when you have your BlackBerry 10 device already added in QtCreator, you can go to &quot;Tools <s>&gt; Options</s>&gt; Devices <s>&gt; Select your device&amp;quot; (on Mac: &quot;Preferences</s>&gt; Devices <s>&gt; Select your device&amp;quot;) to see details about your device. The &quot;Type Specific&amp;quot; section offers you to:<br />* specify an existing file with a debug token generated for your device<br />* request a new debug token for your device<br />* upload the debug token to your device
<br />[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-Devices-BlackBerry.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Options-Devices-BlackBerry.png]]
<br />To create a new debug token click on &quot;Generate&amp;quot; or &quot;Request&amp;quot; button to open a &quot;Request Debug Token&amp;quot; dialog.
<br />[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Request-Debug-Token.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Request-Debug-Token.png]]
<br />There specify:<br />* a path for file that will hold the debug token for your device<br />* device PIN</s> this should be automatically retrieved if your device is attached to your host machine<br />When you press OK, the new debug token file is created and assigned to your device configuration.
 
'''''Note:''''' that you need to press Apply to make those changes been applied to QtCreator settings.
 
In case you have created a new debug token, you need to upload it to your device too so QtCreator and BlackBerry 10 device are using the same debug token. Press &quot;Upload&amp;quot; button in &quot;Type Specific&amp;quot; section of the device configuration. You should see configuration dialog, when the debug token is successfully uploaded.
 
=== Assigning Device to Kit ===
 
* Go to &quot;Tools <s>&gt; Options</s>&gt; Build &amp; Run <s>&gt; Kits&amp;quot; (on Mac: &quot;Preferences</s>&gt; Build &amp; Run <s>&gt; Kits&amp;quot;) to list available kits<br />* Select a kit that you would like to work with<br />* Make sure that your kit is having Device Type field set to &quot;Blackberry Device&amp;quot;<br />* Select your device in the &quot;Device&amp;quot; field<br />* Make sure that your &quot;Qt mkspec&amp;quot; field is set correctly (for physical devices, use &quot;&quot; or &quot;blackberry-armv7le-qcc&amp;quot;; for simulator, use &quot;blackberry-x86-qcc&amp;quot;)
<br />'''''Note:''''' similarly to &quot;Devices&amp;quot; page, if you make any change in &quot;QtVersion&amp;quot; tab press Apply button to store the changes otherwise other pages will not notice your changes.
<br />h2. Creating BlackBerry 10 Application
<br />There are several project templates that can be used for creating BlackBerry 10 project. You can access it via access the wizard via &quot;File</s>&gt; New File or Project…&quot; main menu.
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/File-New-Project-Applications.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/File-New-Project-Applications.png]]
 
In the &quot;New&amp;quot; wizard, the &quot;Applications&amp;quot; category contains the following project templates that allows creating applications for BlackBerry 10 device:<br />* Qt Quick Application<br />* Qt Widgets Application<br />* Qt Console Application<br />* BlackBerry Cascades Application
 
'''''Note:''''' if you are unable to see &quot;BlackBerry&amp;quot; project template, select &quot;All Templates&amp;quot; in the top-right corner of the dialog.
 
=== Qt Quick Application ===
 
This template is generic for Qt Quick applications for any platform. They can be used even for BlackBerry devices.
 
You need to select to use a BlackBerry kit - either in the project wizard itself or add BlackBerry kit to the project any time later. When you do so, IDE asks you whether you want to generate BAR Descriptor.
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Setup-Application-Descriptor.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Setup-Application-Descriptor.png]]
 
Answer &quot;Yes&amp;quot; to bar-descriptor.xml is created in your project and added into &quot;OTHER_FILES&amp;quot;.
 
'''''Note:''''' The bar-descriptor.xml file is created just once only and when you are assigning a BlackBerry kit to a Qt4/5 project. This way use can take any existing QtQuick 1/2 project and all deployment to BlackBerry 10 devices just by assigning a BlackBerry kit to your project.
 
'''''Note:''''' The template allows you to choose Qt Quick Component Set as &quot;Qt Quick 1.0&amp;quot;, &quot;Qt Quick 2&amp;quot; or &quot;Qt Quick Controls 1.0&amp;quot;. &quot;Qt Quick 2&amp;quot; and &quot;Qt Quick Controls 1.0&amp;quot; requires Qt5 runtime which is not available on BlackBerry 10 devices including 10.2 version.
 
=== Qt Widgets Application ===
 
The &quot;Qt Widgets Application&amp;quot; project template provides an application that is using QtGui and QtWidgets library. if you choose to use any BlackBerry kit, you will be asked whether bar descriptor file should generated. Then the application can be deployed and launched on BlackBerry device the same as for QtQuick applications.
 
=== Qt Console Application ===
 
Using this project template is similar to &quot;Qt Widgets Application&amp;quot; project template.
 
=== BlackBerry Cascades Application ===
 
This project template create a project with a preset main.qml to use Cascades UI.
 
'''''Note:''''' Cascades UI FW is available in Qt4 runtime on BlackBerry devices and simulators only.
 
=== Deploying Qt Applications ===
 
BlackBerry 10 devices are having Qt4 runtime automatically available for you in &quot;/usr/lib/qt4&amp;quot; folder. The project-templates and bar-descriptor.xml generated by QtCreator are using this Qt4 runtime.
 
BlackBerry 10 devices are NOT shipped with built-in Qt5 libraries and therefore you need to supply them manually.
 
See &quot;Qt on BlackBerry devices&amp;quot;:Qt-on-BlackBerry-devices page for more details.
 
== bar-descriptor.xml File ==
 
The &quot;bar-descriptor.xml&amp;quot; file specifies the parameters for identifying, installing, and launching native applications on BlackBerry 10. It contains mainly information about the application author, id, icons and other properties and is used to create the ''BAR'' file or ''BAR package''. A BAR package is a installation package of an application for the BlackBerry 10 platform. &quot;BAR&amp;quot; stands for &quot; '''B''' lackberry '''A''' pplication a '''R''' chive&amp;quot;. For more details please refer to &quot;bar descriptor file documentation&amp;quot;:http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/c_about_bar_app_descriptor_file.html
 
QtCreator provides a UI editor for editing your bar-descriptor.xml and manage your application's behavior and appearance.
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Bar-Descriptor-Editor.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Bar-Descriptor-Editor.png]]
 
The Bar Descriptor editor has 4 tabs:<br />* General - edits name, descriptor, icon, splash screens, package information, author information<br />* Application - edits orientation, chome, application arguments, permissions, environment<br />* Assets - edits a list of assets that are packaged into your application<br />* XML Source - edits the bar-descriptor.xml using text editor
 
'''''Note:''''' a newly created project has the bar descriptor file listed as a '''bar-descriptor.xml''' file under &quot;Other files&amp;quot;. This file will be used by QtCreator to generate a final bar-descriptor.xml in the build directory to package your application. For example &quot;SRC_DIR&quot; is replaced with your project directory path.
 
[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Bar-Descriptor-File.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Bar-Descriptor-File.png]]
 
If you run the application now, QtCreator will create the bar package, connect to the device or simulator and launch your application. You can also do these steps using commands in a shell, see the next section for more details.
 
For performance reasons, the log output from qWarning, qDebug, etc is captured by the &quot;slog2&amp;quot; logging system on BlackBerry 10 instead of plain text files in the file system. All these messages will appear unfiltered in the &quot;Application Output&amp;quot; view.
 
If you want to use command-line to package and deploy your application, see the following page:<br />* &quot;Command-line Tools&amp;quot;:http://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/c_understanddevenv_use_commandline.html<br />* &quot;Packaging and Deploying&amp;quot;:http://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/c_wf_about_package_deploy_app.html
 
== Import Momentics Cascades Project ==
 
If you are having an existing Cascades project that has been created using QNX Momentics IDE, then such a project cannot be directly used in QtCreator. Instead you need to import such a project into QtCreator:<br />* Go to &quot;File <s>&gt; New File or Project…&quot;<br />* Select &quot;All Templates&amp;quot; in the &quot;Choose Template:&quot; combobox in the top-right conner of the wizard<br />* Select &quot;Import Project&amp;quot; in category listing<br />* Select &quot;Momentics Cascades Project&amp;quot; in the project listing
<br />[[Image:https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Import-Momentics-Cascades-Project.png|https://raw.github.com/blackberry/Qt/master/screenshots/Qt-Creator-with-BlackBerry-10/Import-Momentics-Cascades-Project.png]]
<br />* In the next page of the wizard, specify a folder that contains .pro file of your Momentics Cascades project<br />* In the next page, specify the new name and location of your new project<br />* Press Finish
<br />Your Momentics Cascades project is going to be read and a new QMake-based project is going to be created at a specified location. Note that the new project is a converted copy of your original project. The original project is not modified by the Import wizard.
<br />When the project import finishes, &quot;import.log&amp;quot; is created next to your .pro file of your application. The log file contain information about the importing process.
<br />h3. UI Adaptability
<br />Note that QtCreator does not understand &quot;UI Adaptability&amp;quot; concept used in BlackBerry applications. Still your imported project will contains all (QML, images, resources) files</s> even those that are stored in the non-default selector folders.
 
QtCreator will be unable to correctly resolve references to other QML files that are relative due to UI Adaptability.
 
Still when you run such an project in a BlackBerry 10 device or simulator, UI Adaptability will work in your application.
 
=== Zygote Applications ===
 
The import process convert the bar-descriptor.xml and .pro files of your application. It strips the code that is related to &quot;Zygote&amp;quot; your application. This will reduce the start up of your application but should not affect its functionality.
 
=== Localization ===
 
The import process convert the bar-descriptor.xml and .pro files of your application. It strips the localization support aka the &quot;translations&amp;quot; folder and its inclusion into BAR package.
 
== Known Bugs ==
 
=== Qml Profiler Tool is not supported by QtQuick1 applications for Qt ver. &lt;= 4.8.6 ===
 
For more information see QTBUG-36144. This bug affects QtQuick1 applications only. The Cascades applications can be still profiled as expected.

Latest revision as of 13:04, 2 March 2015