Sunday, August 12, 2012

(Dis)Adventures in the Land of QT

So I had bought this N9. Beautiful phone. It's only mistake was to be born 4 years too late into the world.
And to work on QT.


 I am a beginner QT developer. This might sound funny, but it is not. It is dead-serious. There is this app I am coding, and I NEED desperately in order to be able to edit the bookmarks from the default browser on my N9 (since Nokia did not deserve it the time, unfortunately).


QT sucks.

Well, not really to be honest. It is great. Really. It does NOT suck, as said, because it's portable, it's flexible, it has every thing that you need, it has tools for every thing (really!), and a language for everything. In short, in the world of multiplatform, QT is a very, very strong God. Nice. But it simply sucks. In some ways. Especially the Windows way. The multiplatformness for Windows is simply not there yet, or not as advanced as the user (=you or me) would think it is.

So, as a beginner QT developer, with a QT phone, a Windows-based machine, what do you do? You code! On your amazing N9 phone! So you download, install, and start fiddling around (and get to know) well, QT. The first thing you realize is that QT has a pretty strong and high learning curve. This is normal. It's huge. Multiplatform. Holy shit. But do not despair! There are examples! Bring up the examples, compile them, and realize after a whole bunch of time (approximately 1 hour of searching around) that some of them will never work on your phone, and for these the multiplatform lable is but that: a label.


Well, anyway. The good old extreme way of programming never failed you. So you fire up a new project in QTCreator (sounds like Populous all over again), start a new project, and...wait a moment, there are like, what, 15 project types to choose from! Wow! But which one is mines? The Qtmobile? Must be! Rewind.
So you fire up a new project on the QTCreator for Qt Mobile. A very simple "Hello world". The traditional.
Nothing extra. Compiles, packages, runs. Wow! It works! You have the proof!
Now you want to expand the feature set of your app. Where to start from? Google is your friend! Examples too, but as mentioned, not all of them work. If we assume that you :

a) have installed the examples through the SDK Installer (or QTCreator's updater).
b) have found them in the QT SDK
c) have managed to get the example to run

Suppose now you make it as far as having a C++ backend, a QML frontend for your nicely growing app.
You managed to get all the functionality in it, and have it running on the phone - but wtf? You just realized special characters are not displayed..instead, question marks (??) or other uncommon ASCII characters are not displayed. Where do you look first? I can tell you, in the string handling. And you will loose alot of time in there. Why? Because the problem is not in the string management. QT handles strings beautifully.
But there is the fact that (for apps that have to support UTF-8)  QML files need to saved as UTF-8 format in order for the QML viewer to be able to display correctly UTF-8 characters. WTF? Guess what't the default text file format ON WINDOWS?? UTF-8? Response : NO. It's some weird ISO number that I do not even want to remember. Time for searching : 1 hour & 1/2 (Total so far : 2 & 1/2).
Add another three hours to your count (if you are lucky enough to find this small note).

Want to have the confirmation of the crappy Windows support for QT?
Once this last hurdle is passed, you might actually find yourself wanting to test the app.
So you have two ways. Simulator for N9, or real device. My suggestion is : use the simulator whenever possible, debugging on real device is fucking slow. iPhone in this sense has alot better development setup.
But hah! Assume you developed a C++ QML plugin. You need to deploy it correctly. For that, you need to find the correct folder for it (which btw is /Simulator/Qt/mingw/imports). And then enter the battle of QMake, because the deployment option for the simulator is missing from QT Creator.

So, you see. All in all, Qt has alot of potential. Alot of features. And everything you need to code once and deploy everywhere. Really. The tools support for Windows, tho, can pose some challenges (especially QMake deployment).

No comments: