Want to start developing/porting Qt apps to Blackberry Playbook but don't want to dive into Qt libraries compilation? If yes then this article is for you, it lets you jump directly to developing Qt app skipping tedious process of compiling Qt libraries first.
We'll be speaking here only about creating Qt application to be deployed to Blackberry Playbook Simulator (Qt library below is compiled for x86 architecture).
1. Prepare your MS Windows system
1.1. Download Native SDK for Tablet OS 2.0 from here https://bdsc.webapps.blackberry.com/native/download/ and install - very straitforward process.
1.2. Create a folder C:\qt-x86-lib (you can create a folder wherever you want, this path will be used in this article)
1.3. Download Qt library from http://qt-qnx.tm-k.com/qt-x86-lib.tgz and save it into C:\qt-x86-lib\ folder created in 1.2. This is a set of Qt libraries precompiled for x86 platform and suitable only for Simulator. This is not something that is being built nightly but it's fresh above and proved to work. Probably with time if there is enough interest in the project I'll setup something more serious to follow current Qt development repository.
1.4. Unpack qt-x86-lib.tgz archive using any archivator that understands .tgz format (my favorite one is 7zip). You should get C:\qt-x86-lib\stage\... and lots of files/folders underneath.
That's basically it, now you can start develop Qt app.
2. Create QTHelloWorld project in Momentics IDE
Start Momentics IDE.
Click File->New->BlackBerry Tablet OS C/C++ Project and in Project Name: specify QTHelloWorld, hit Next and Basic Setting will open.
- check Language: C++
- Build Style: Managed build
- Project Type: Application-Empty Application
Click Next and Build Configurations will open, we want Simulator-Debug here. Click Finish.
At this point we have an empty project with bar-descriptor opened for you in IDE. You can put whatever you want at General Page:
Click Assets tab and then make sure to select Simulator-Debug at Build Configurations panel. Then click Add Files... then File System... and select your libQTCore.so.4.8.0 that you should have in qt-x86-lib\stage\nto\x86\usr\lib\qt4\lib\. Do the same for libQtGui.so.4.8.0, libQtOpenGL.so.4.8.0. Now add one more file: C:\qt-x86-lib\stage\nto\x86\usr\lib\qt4\plugins\platforms\libblackberry.so. Now we have to correct one line in bar-descriptor.xml. Click on Source tab and locate the line
<asset path="C:/qt-x86-lib/stage/nto/x86/usr/lib/qt4/plugins/platforms/libblackberry.so" type="Qnx/Elf">lib/libblackberry.so</asset>
Change it to:
<asset path="C:/qt-x86-lib/stage/nto/x86/usr/lib/qt4/plugins/platforms/libblackberry.so" type="Qnx/Elf">lib/platforms/libblackberry.so</asset>
Click File->Save all...
Now you should have picture similar to this:
Now let's add source file main.cpp to the project. Right click on src folder in Project Explorer and choos New->Source file, in Source File: field put main.cpp and hit Finish.
Main.cpp will be opened for you, copy paste following code:
int main(int argc, char *argv)
QApplication app(argc, argv);
QPushButton quit("Quit", &window);
quit.setGeometry(422, 100, 180, 40);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
Click File->Save all...
Now it is time to change some compiler/linker settings. Right click on QTHelloWorld in Project Explorer and choose Properties. Make sure you set up right things in Configuration:, Include Directories (-l) and Defines (-D) as shown on the picture:
Now set up your libraries this way:
Let's try to build - click Project->Build Project. In Console you should eventually see "Build complete for project QTHelloWorld". Congratulations! it's already something...
Now hit Run->Debug Configurations... You need to specify -platform blackberry at Arguments tab. And at Environment tab check that you have LD_LIBRARY_PATH=app/native/lib (sometimes it is missing, don't know why). Click 'Debug' and after the project is packaged and deployed to your Simulator you will be switched to Debug Perspective and the program execution will stop at main().
Now you know what to do -) Enjoy!
PS: many thanks to http://hecgeek.blogspot.com/2011/10/qt-for-blackberry-playbook.html who gave me the very first hint how to start.