Why I completely dropped Qt and QtWebKit from my Hybrid App

In my recent articles I described certain aspects related to the use of QtWebKit in a hybrid C++ application. In the meantime, it turned out that Qt and QtWebKit are not such a good bet as I thought they would be at the beginning. Here’s why:

Apple

First and foremost, the most interesting question in a hybrid app written in C++ is: where do you want it to run? In my case, it is on Mac OS X in the first place, then on Windows and very likely also on Apple’s iPhone or iPad. However, this puts me in a situation where I have to decide which subset of these platforms I support primarily and which ones secondarily as there is no such thing as a common layer to access all of them from a single code base. It is either a combination of Mac OS X and Windows via the Qt port or a combination of Mac OS X and iPad/iPhone that can go as the primary target.

For a certain time, I concentrated on the first combination as shown above while hoping that time works for me and somebody ports Qt to the iPhone, and there already is a project for that at http://www.qt-iphone.com/Introduction.html. But, in the meantime, Apple introduced iPhone OS 4.0 and *bam* there will never be such a thing, because http://daringfireball.net/2010/04/iphone_agreement_bans_flash_compiler “and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited)”, a rule introduced by Apple which is actually targeted against Adobe and its Flash technology but will also affect Qt, especially because that comes from Nokia, another one of Apple’s (future arch) rivals. This means that Qt can never be the common layer on all of my targeted platforms. Given that, and the fact I target Mac OS X first, Windows second, and that I also tend to shift Windows one step further down and promote the iPad version instead which completely changes the porting picture:

This looks much cleaner now as it provides unified, access to all Apple platforms. For Windows and Android Google Chromium is a good choice.

But what about Qt in general?

Qt / Nokia

The first part was the rational part, here comes the emotional one:

In the recent weeks I had enough time to dive into the details of Qt in all aspects. Its visual quality, its API quality, its implementation quality and the quality and structure of their development process. My conclusion from that is that it is the wrong way of doing things as evaluated from a broader perspective.

What is very important in a visual app is visual quality. Qt does a good job in replicating functionality of controls on each addressed platform. But, it can never, by its nature, take care about the special controls certain platforms offer because then it wouldn’t be cross-platform any more. Qt certainly has to focus on the lowest common denominator across all supported platforms. By driving the GUI via Qt controls, an application loses the capability to provide the eye-candy to the platform user like he is used to. The most prominent example of this is Google Maps which is based on Qt and which totally lacks platform L&F on the Mac up to a degree where it certainly loses style. In Google Maps this is not so important as interaction with the Earth requires a special user interface anyway and the rest of the app is unimportant, but it shows how difficult it is even for Google to provide attractive visual quality on the platform. Gaining access to the platform specialities is difficult as everything is hidden by Qt in private implementations. You have no chance to do “that special thing”.

Qt has a comprehensive “fat” API that consumes everything from all platforms and which has to take care about the specialities on all platforms, which is of course its nature but which is also very difficult to maintain and to improve over years. Development of Qt is distributed across Europe with Nokia focussing on minimizing cost not maximizing quality. Their development centers are mostly in cheaper parts of Europe and they try to cooperate with educational institutions to bring the costs down. This might be a legacy from Trolltech but is still in place and shows that quality is not their first concern.

So far I have touched Qt releases 4.5, 4.6 and 4.7 and came across older API documentations. From there I can tell that many things they have done are not very well and strategically thought out. They introduced too many APIs doing similar things and deprecating previous ones (QML, QtQuick, Scripting with QtScript and in QtWebKit, Qt3 vs. Qt4, QGraphicsScene, QItemView, QtDesigner, QtCreator). To me this is too much feature driven and dictated by the progress of other market players. Then I saw these super new technologies contrasted by very basic demo videos in YouTube showing excitement over very basic features which is not very professional – you can check out their channel on http://www.youtube.com/user/QtStudios to get an idea. What I want as a consumer of platform technology building a commercial grade application is that the selected platform is very stable and well thought out. But there is just too much noise coming from Qt and to make matters worse, none of the new features really feels final, it feels more like work in progress and you can never know how long something survives. Last not least, one day down the road Nokia might become a rival again to Apple just as relevant as Google now is. Economically speaking, Nokia already is, but Apple sees Google as its main competitor, not Microsoft and not Nokia. They are just not in the same technology league any more. Apple and Google have the brains now.

Don’t get me wrong, the Qt guys are doing a good job and they surely do it with a lot of enthusiasm, all I want to say is that Qt is just not the best bet in a commercial hybrid application. That is why I gave up on it.

Advertisements

6 thoughts on “Why I completely dropped Qt and QtWebKit from my Hybrid App

  1. Just because Google Earth is written in Qt and does not have the Mac L&F, you are too quick to conclude that all Qt-based application “loses the capability to provide the eye-candy to the platform”. It’s Google Earth issue, it has nothing to do with Qt. For example, check http://doc.trolltech.com/qq/qq23-layouts.html where special attentions are given so that even the widgets margins and spacings match to those of the native Aqua.

    For “Development of Qt is distributed across Europe”, where did you get this fact? Last time I checked the Qt developers are mostly in Oslo, Berlin, and Brisbane.

    Some further comments on Qt from you are more subjective and hence I will not comment on it, unless you can show more substantial examples, like those of “deprecating previous ones”.

    Also, judging a framework from the reaction of its YouTube channel users is likely a hit-and-miss. You should check Qt Labs instead (and its archive) for a better peek on what happens inside the Qt kitchen.

    • Ariya, thanks for your comment and my apology for being so emotional, but the decision was not an easy one. And there are of course rational and irrational aspects to a decision. We are still people 😉

      You are right, it might actually be possible to create a Qt app with L&F close to the platform standard, with some extra effort, as you already documented with that link. The question is though: at what price? I’m sure Qt does not offer the very special Mac widget types out of the box, so you would have to reprogram them, but these are the ones that make up the platform eye candy. In case of Google Earth you can argue that indeed Google is to blame, but what you then actually say is that Google should create a special Mac OS X version and a special Windows version and a special XYZ version even if they are all Qt based, and then the whole Qt based approach becomes questionable as it moves away from the cross-platform paradigm. Then you might as well just program against the native platform toolkits at perhaps similar costs but with the benefit of real platform nativity. Surely everything can be done, but everything also has a price tag. BTW, do you actually know at least a good example of a well-done Qt application with a decent Mac OS X GUI? I couldn’t find one…

      IMO, Trolltech’s development structure was absolutely appropriate when it was Trolltech, given that most of Qt is open-source and needs community knowledge, marketing and development. That is why Trolltech took the distributed approach and it was fine, but from Nokia I would expect a more headquartered approach in order increase productivity in one of its key products. Don’t get me wrong, they can do what they want, the decision is on my side. Do I trust them enough to base an applications architecture on their product? I don’t, and that’s what my post was about.

      In Qt4 they introduced a whole bunch of new APIs, and even in the subsequent minor versions things have been added quite frequently. The thing is, in a project you program against what’s there, and not against what might come, because you don’t know that. Their approach should be: Do it right from start, especially in a highly dependent environment like Qt. If I make a decision towards Qt today then I must be prepared that they will change things like they did in the past. There will be for instance a QtWebKit 2.0 coming soon introducing perhaps again a different or extended API and QtWebKit will be spun off from Qt completely. These expected changes are simply a project risk, even if they are benefits, but you have to deal with them because you want the functionality, so you end up living in the lifecycle of Qt.That can be ok, but you need to be aware of it.

      You got me not quite right with the videos. I wasn’t referring to the YouTube users, I was referring to the content of the videos. If you take this one for example http://www.youtube.com/user/QtStudios#p/u/12/sQnb7g_jSM4 this tells me that they are excited over very basic (and ugly) things which isn’t quite what I would expect from Nokia. Or this one here: http://www.youtube.com/user/QtStudios#p/u/13/ubW3GM9NzS4 it should be quite clear that long running tasks must be done in a different thread. Those things are just basics and shouldn’t be shown in an official video channel because that leaves room for interpretation where they actually stand.

      • Do you have any example, where such an app was created without involving Qt or any other UI toolkit, but just WebKit?

      • No, and I don’t think there is any. I think that is because it seems to be a very expensive approach:

        1) the WebKit build process: All current ports are part of the WebKit build process. You would need to spend a considerable amount of effort on integrating into the WebKit build or to integrate the WebKit build into your own build. Qt has done the latter, and that could be a blueprint for you.

        2) WebKit interaction with the platform: WebKit needs to interact with the platform in many ways: e.g., for networking, drawing, getting user input etc. – those things all need to be provided to WebKit from your app.

        3) code integration: each WebKit wrapper adds code to the WebKit codebase, controlled with #ifdefs, in many cases just a pointer or a conversion function from the wrapper’s string type and such. You would need to do that as well whereas it might be very hard to maintain your extensions outside of the original code base as you still want to consume changes from WebKit downstream. You might be able to do that with git merge. And to create a new port for your app inside the WebKit repository should not be an easy one for administrative or political reasons at WebKit.org.

        That is why it seems to be so much easier to start with an already wrapped WebKit. I’m using Apple’s WebKit framework now. I could also have used Chromium instead but I would lose the iPhone/iPad support so I decided to stick with Apple and since they are the inventor of WebKit they aren’t the worst bet as I think they still set the pace for the other ports and they provide a very powerful integration between the JavaScript engine and the Objective-C platform.

    • Snow leopard widgets differ slightly from the ones in QT. QT widgets are from the older version of mac.

  2. apareis :
    No, and I don’t think there is any. I think that is because it seems to be a very expensive approach:
    1) the WebKit build process: All current ports are part of the WebKit build process. You would need to spend a considerable amount of effort on integrating into the WebKit build or to integrate the WebKit build into your own build. Qt has done the latter, and that could be a blueprint for you.
    2) WebKit interaction with the platform: WebKit needs to interact with the platform in many ways: e.g., for networking, drawing, getting user input etc. – those things all need to be provided to WebKit from your app.
    3) code integration: each WebKit wrapper adds code to the WebKit codebase, controlled with #ifdefs, in many cases just a pointer or a conversion function from the wrapper’s string type and such. You would need to do that as well whereas it might be very hard to maintain your extensions outside of the original code base as you still want to consume changes from WebKit downstream. You might be able to do that with git merge. And to create a new port for your app inside the WebKit repository should not be an easy one for administrative or political reasons at WebKit.org.
    That is why it seems to be so much easier to start with an already wrapped WebKit. I’m using Apple’s WebKit framework now. I could also have used Chromium instead but I would lose the iPhone/iPad support so I decided to stick with Apple and since they are the inventor of WebKit they aren’t the worst bet as I think they still set the pace for the other ports and they provide a very powerful integration between the JavaScript engine and the Objective-C platform.

    Thanks for providing more insight. But if I have existing Hybrid apps developed on Qt-WebKit, and now want to change to Android-WebKit, whether the HTML, CSS, JS code can be used as it is?
    I understand that the C++ code to interface with JS environment would have to be changed. Whats your opinion on this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s