Nokia N9 powered by Harmattan is a Qt enabled phone. Development of an app is quite rapid and toolchain is very tolerant and forgiving.
A few months ago, I tried BlackBerry10 NDK. At the time, development was everything but rapid and smooth.
Today with OS release 10.1. I wanted to give it another chance.
Evil tongues will say I'm biased. Those who know me also know that my loyalty remains with Qt. No matter what manufacturer or governance is in charge.
I do have one advantage. I started to learn Qt with 4.6.1 release. There was no QML at the time. With that said, I'm not affraid of C++ nor is it strange for me to work with Qt Core.
I'll try to keep that in control and whatever you don't understand the topic at hand, ask in comments below.
BlackBerry10 NDK provides QNX Momentics as an IDE. Face the truth, it's Eclipse. Perspectives and windows were added to fit BlackBerry10 development but I still hate it as much as I hate vanilla Eclipse. Why give me 100 buttons if I'm going to need only 5 and console output?! My first attempt a few months ago resulted in using Qt Creator and BB10 Kit setup. In theory it works, but I really don't recommend doing this with Qt Creator, version less than 2.7. Autocomplete doesn't work and syntax highlighting is a bit flaky. QNX Momentics it is then!
Without going into details how to create a new project, I can say that on both platforms this is really straight forward. Click, click, click and you're done, you got a Hello World template. BlackBerry10 does require 1 special moment of attention and it's name is bar-descriptor.xml.
Default bar-descriptor.xml autogenerated by Momentics is a good basic layout for you to improve. You can use the recommended way of doing this, following UI and tabs on editor window, or you can edit the source of the file itself.
Often overlooked, splashscreen is an important part of your app. After the icon, it is the first part your users will see. BlackBerry Z10 has support for both portrait and landscape splashscreen. BlackBerry Q10 uses just 1 rectangle shaped image. It is possible to support both at once. Use the UI for editing and upload those 3 images. You must obey the resolution for orientations and NDK will take care of the rest. Splash images will deploy and show up properly on both devices. You need to make PNG images in resolution 720x720, 1280x768, 768x1280. Put those in your projects root directory and load them in bar-descriptor.xml. It will result in code like this:
<splashScreens> <image>spashQ10.png</image> <image>splashZ10Landscape.png</image> <image>splashZ10Portrait.png</image> </splashScreens>
Another thing I was looking for is how to switch from white to black theme. I find the black theme more elegant and eye soothing any time. Honestly, every blog post I looked at had the old XML nodes and those changed:
<env var="CASCADES_THEME" value="dark"></env>
Please notice that values are dark (black) and bright (white) for themes. I do expect BlackBerry to provide a way for developers to make apps that can change the theme while the app is running. We do have that on Harmattan.
Looking at the project tree you can see quite a lot can be reused. Just remember that BlackBerry10 insists on some subfolders and hierarchy while Harmattan is more freeform. Depending how tidy you are, these 2 can be mergerd quite easily.
In short, your Headers and Sources from Qt Creator go into src subfolder and your QML reflects into assets when looking from Harmattan into BlackBerry10 in Momentics structure.
Moving along, next stop is main.cpp. This is the point where we fork a little. Harmattan has a declarative engine while BlackBerry10 has a graphics engine and their own respected views. It is a crude comparison and very much so simplified but details about this can be the topic of another post. It boils down to this: on Harmattan you use QmlApplicationViewer while on BlackBerry10 you use QmlDocument. Potatoes, patatas, if you don't demand something very exotic in your code.
BlackBerry10 default template also comes a little bit better prepared, including translations and some debugging options. You had to type those in manually on Harmattan.
Now for the sweet stuff. QML code. Take a look at these 2 screenshots below.
Going from top to bottom on both pictures and comparing, you can see the layout has been preserved. Both use Page as the root component. Both have a TitleBar. Custom made component on Harmattan, comes out of the box with BlackBerry10. Here comes the creepy part. While on Harmattan you had Flickable and Column design, on BlackBerry10 for the same effect you can use ScrollView, Container and StackLayout. It looks clumsy on BlackBerry but it actually isn't. This very combination and layout of Page will produce code that works well both on Z10 and Q10. Inside our, now flickable page is a component called GroupSeparator or Header. It follows each OS UX and again, custom made on Harmattan, comes with BlackBerry10. If you look at the component just under Type header you'll think at the first glance these are just 2 buttons. Well, they are on Harmattan, nested in ButtonRow. However on BlackBerry10, this is called a Segmented control. Name is rather self explanatory. Use it to change states, enums or properties. Logic behind it is pretty much the same. Next up is a datepicker. A picker of date and/or time. A nightmare to sync up no matter what you do. Both platforms provide solid standard use case solution but this point goes to Harmattan due to flexibility. On BlackBerry10 I was not able to merge together all time and date data in one component. There are 3 modes you can use but none of them provides a full date format with a year included on Blackberry10. How weird is that? Below yet another header component there are 2 most common text input components. Nothing much to add to those, they both work very good. There are some distinct small differences. For example placeholderText on Harmattan is hintText on BlackBerry10. Another cool feature BlackBerry has implemented is automatic parsing of Twitter usernames if you put this in your TextArea:
Added value like that really saves a lot of work for developers like me. You can also compare and see a Label and a Button components used here. Same old, same old, no differences. Except one! You cannot change a Button height on BlackBerry10 using Cascades. Don't ask me why, I have my theories and none of them should be valid. I'd expect this to change at some point in far future. Something that is not shown on these screenshots but it is used is a way to communicate with the user while the app is in use. We all abused InfoBanner on Harmattan for this but on BlackBerry10 it is called a Toast. In order to use such a communication way on Harmattan, you had to import com.meego.extras 1.0. A similar but a wee bit low level way has been implemented in BlackBerry10. Add this to your .pro file and read some docs and you are good to go with Toast.
LIBS += -lbbsystem
I wouldn't be myself if I hadn't found a way to break the interpreter. There is a thing that confuses Momentics a lot at this stage. These things are called expressions. Harmattan was designed to optimize and work with expressions quite fast. Some beautiful one-liner code can be written using expressions. BlackBerry10 does work with them. Your project will build and deploy but your Momentics IDE will throw out error of strange unexpected code. If you throw in some in depth nested expressions too, it just gets worse. I cannot stress out enough that this needs to be fixed.
BlackBerry10 Cascades are provided as they are. There are plenty of them and they all work excellent. Some of them I'd even like to see backported in one way or the other to other Qt enabled platforms. They are that good but they do limit you and protect you of doing funky, stupid stuff. I wouldn't call that taking away the freedom I, myself personally exploit on Harmattan. You just have to work around them because there are always ways to do so. Even when you do make some funky code, it will not shoot you in the foot, wave and jump out of the window with Kernel-Exec thread error 0x003. Like on Symbian, but that's yet another comparison for another post. Point is, BlackBerry is using highest version of Qt currently available on devices sold, Qt 4.8.4. If that means they are leading ahead with Cascades, so be it. I expect great improvements with each update available and so far I was not disappointed.