What "cross-platform" means for a Qt developer

kevinSharp | 02 November, 2010 23:49

I'm at Qt Developer Days this week in San Francisco, and one line of questions I keep hearing from developers relates to the cross-platform promise of working with Qt. It came up in yesterday's Qt Essentials tutorial. I overhear the question in the halls. This morning Nokia CTO Rich Green answered the question in his keynote.

Rich clarified, in essence, that MeeGo and Symbian are two different platforms. "There is no promise of a 'write once, run twice' environment for Qt across Symbian and MeeGo platforms," he explained. There is no guarantee that all software and hardware interfaces available on one platform will be made available on the other. He DID promise that a public interface available on one platform will remain stable on that platform and that developers will know in advance when interfaces will be changed or deprecated. He also said that to the greatest extent possible when a capability is available on both platforms that the interfaces a developer uses to access those capabilities will be identical.

I can provide an example from a conversation I had last week with Forum Nokia Champion Thomas Perl. (The conversation will become a podcast after I return from this conference and have time to edit the recording.)

Thomas is developing a fun little game called That Rabbit game. The game controls use the accelerometer on the device to allow the player to steer game objects by tilting the device. He built an implementation in Qt for Maemo 5 (N900) and then ported it to Symbian^3 (N8) in less than a day. 

Almost everything from the Maemo build worked without modification on Symbian with the following two exceptions:

  1. The accelerometer axes point different directions on Maemo and Symbian^3. The software interface is identical, but where the x, y, and z axes point in relation to the screen orientation do not agree. The natural "up" for a Symbian device is different than that of a Maemo. Solution: a simple compiler directive conditionally inserts code to perform an axes transform if the game is being compiled for Symbian^3.
  2. The N900 does not automatically change from landscape to portrait display mode depending on the orientation in which the device is held; players of Thomas' game were free to steer at will without triggering rotations. That makes sense as a platform behaviour on the N900, not on an N8. Again, a compiler directive automatically inserts into a Symbian build some code Thomas downloaded from the Forum Nokia Wiki to suspend auto-rotation.
That's the difference between cross-platform (which Qt is) and platform-agnostic (which Qt is not). At the end of the day 90%+ of Thomas' code ported without modification from Maemo 5 to Symbian^3. The remaining code relates to differences in platform design, and are easily handled with compiler directives. Thomas still has a single code base, so any upgrades he makes to the core gameplay automatically flow to both platform builds.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved