Before we begin, I'm going to make the following assumptions:
- You are using Linux (MacOSX is probably similar, Windows probably has more differences)
- You have a Git client installed
- You have installed the Native SDK in: /opt/RIM/bbndk
- You have already requested and installed code signing keys
- You have generated a debug token, and saved it in your home directory as "debugToken.bar"
- You have an actual PlayBook, on an IP address your computer can connect to, that is in development mode with the above debug token installed.
Downloading and Building QtFirst, put the following line at the bottom of your .bashrc file:
(Seriously, just do it. If you don't, then I don't want to hear all sorts of complaining about how various commands can't be found during the build processes to follow. If you insist on not putting that in your .bashrc, then make sure you run it in every single new shell window you open before doing anything I'm about to discuss.)
Now, time to download and build Qt:
~/pbdev$ git clone https://github.com/blackberry/Qt.git Cloning into Qt... remote: Counting objects: 46226, done. remote: Compressing objects: 100% (29220/29220), done. remote: Total 46226 (delta 14755), reused 45939 (delta 14468) Receiving objects: 100% (46226/46226), 158.41 MiB | 832 KiB/s, done. Resolving deltas: 100% (14755/14755), done. ~/pbdev$ cd Qt ~/pbdev/Qt$ ./configure-qsk arm v7le . . . Qt is now configured for building. Just run 'gmake'. Once everything is built, you must run 'gmake install'. Qt will be installed into /home/octo/pbdev/Qt/stage/nto/armle-v7/usr/lib/qt4 To reconfigure, run 'gmake confclean' and 'configure'. ~/pbdev/Qt$ make . . . ~/pbdev/Qt$ make install . . .
Your first Qt appYes, now I'm going to show you how to build/package/install a simple "hello world" application. Once you get past this point, its mostly normal Qt development.
This example application consists of the following files, which I'll describe in detail below:
|main.cpp||source code for the application|
|helloworld.pro||qmake project file|
|blackberry-tablet.xml||bar descriptor file|
|splashscreen.png||1024x600px splashscreen image|
This is a pretty basic Qt sample application so far. The only unique part is the first line, where we are explicitly telling QCoreApplication to add a library path. This is necessary to enable the application to find the QPA plugin that RIM provides as part of their Qt port. What is important to note is that the path is relative to the directory the app will be executed from on the device.
This file does a lot of important things:
- Configures the linker to hard-code the path, relative to the directory the app will be executed from, where the Qt libraries will be installed
- Includes the "bbsupport" library, which allows the app to interface with the device in a Qt-friendly way
- Adds a special make target ("make helloworld.bar") that builds a BAR file with the following characteristics:
- Development-mode build, using a debug token
- Passes command-line arguments to use the "blackberry" QPA plugin
- Bundles all the resources and libraries our app may need
The descriptor file is pretty standard for the PlayBook, and described in far greater detail within RIM's own documentation. The graphics are not provided here, but you can use any appropriately sized PNGs of your choosing. If you omit the splash screen, remember to remove it from the descriptor file as well.
Building and installing
And that's all there is to it! If the size of the BAR file bothers you, try experimenting around to see if you can get away with including a smaller subset of the Qt libraries or building Qt with fewer features. However, the bulk of that size is from QtCore and QtGui.