Android vs. Qt: A Mobile Developer's Comparative Review

February 17, 2012

Although the Android and Qt mobile development platforms have architectures that are quite different, they share a common goal in providing a productive framework for developing mobile applications. While Android has gained a stronghold as a rich application development platform for smartphones, Qt with the introduction of Qt Mobility and Qt Quick is nevertheless a strong contender in the arena.

In this article, I will compare and contrast the Android and Qt platforms from a developer's perspective.

Android vs. Qt: Platform Overview

Most Android applications are developed in Java and they run in the Dalvik Virtual Machine. However, Android borrowed only language syntax from Java and it does not provide standard APIs such as those found in Java SE and Java ME. Device services such as touchscreen and storage are accessed through the Google Services API.

The Android operating system is based on the Linux kernel but not a Linux OS per se. It has neither a native windowing system nor any support for standard Linux libraries such as GNU C. To run an application written in C or other languages it has to be compiled to native code, can be done with the Android NDK.

Qt is a cross-platform framework targeted towards Symbian, Maemo and MeeGo. Though Qt provides binding for several programming languages such as Python, Ruby and Perl, applications are predominantly written in C++ and enhanced with additional extensions. These extensions are implemented by a pre-processor that generates standard C++ code before compilation. The Qt framework is best known for its ease of use and its support for excellent GUI widgets for desktops. Its recent enhancements to mobile platform, particularly Qt Mobility and Qt Quick, are intriguing. With its robust Qt Creator IDE, the Qt framework is gaining a foothold in the mobile application development space.

Android vs. Qt: Application Components and APIs

The main concept in the Android architecture is component reuse. This allows publishing and sharing of activities, services and data with other applications. Android has four basic components, each serving a specific purpose. Software built on Android will be using more or less the following application services.

Activity Manager: This controls the lifecycle of any activity including management of the activity stack. An activity provides an interface for user interaction. This is the basic building block of Android applications and is responsible for creating a window. All activities are subclasses of android.app.Activity, where UI elements are set through setContentView(View). Views are used for UI construction.

Services: Service components run in the background, basically to perform lengthy operations or remote processes. They have no UI and are implemented as subclasses of android.app.Service.

Content Providers: These components act as repositories for shared data, be they file systems, SQLite databases or other persistence storage locations. Content providers are implemented as a subclass of android.content.ContentProvider.

Broadcast Receivers: This component acts as the respondent to the system's broadcast announcements as battery is low, screen turned off, etc. It is implemented as a subclass of android.content.BroadcastReceiver.

Qt has a different way of handling what Android does with activity. It uses several components such as domain classes or state machines for tracking component state. With previous versions of Qt, when creating a UI you had to use widgets or build your screens on top of QGraphicsView. The result was a poor user experience, especially on touchscreen phones. But with the introduction of Qt Mobility and Qt Quick, application development in the Qt mobile platform has become more pragmatic.

The QtMobillity API framework offers a wide range of features and technologies, including:

Bearer Management: This API controls the system's connectivity state, manages available network connections and uses the best available connection.

Contacts: This API enables clients to request contact data from local and remote locations.

Location: This API is used to receive location data from arbitrary data sources.

Messaging: This API is used to send and receive a variety of message types such as SMS and email.

Multimedia: This API helps in playing and recording media, and managing the collection of media content.

Publish and Subscribe: This API is used to share context information between applications and read item values, navigate through them and subscribe to change notifications.

Service Framework: This API is used to discover and instantiate arbitrary services.

System Info: This API is used to discover system-related information and capabilities.

Qt Quick provides a mechanism for declaratively building an object tree with the QML language. The QtDeclarative C++ module integrates QML with C++ objects. Developers can build the types of fluid UIs customary to smartphones and other devices. Review this list to see all the Qt Quick components.

This Qt Quick code snippet provides a glimpse of what the script looks like.

Android vs. Qt: Platform Tradeoffs

Because Android was developed as a platform for mobile phones, access to system resources such as the touch screen, camera, and so on comes naturally to its API. Qt on the other hand is a cross-platform application framework that first targeted desktops before expanding to mobile platforms with the Qt Mobility pack and its APIs. As a result, its mechanism to access system resources is significantly different. Table 1 shows some major Android features and their Qt counterparts.

In Android, the developer can load an application UI from an XML description file or layout designer in an IDE (e.g. Eclipse).

Qt for Symbian provides two ways to design your application: Form Designer in Qt Creator and the QML of Qt Quick for layout design.

Android is based on Java and the Dalvik VM, all powered by the Linux-based Android OS.

Qt, based mainly on C++, is a cross-platform application framework powered by OSes such as Symbian, MeeGo, and MeeGo.

Android applications are restricted to the Android platform, which is designed primarily for smartphones, tablets and other hand-held devices.

Qt is a cross-platform framework designed primarily for desktop development that was later ported to a mobile platform. A properly designed Qt application can be executed on Symbian, Maemo, and MeeGo mobile devices, as well as on Windows, Linux, and Mac OS desktop platforms without any significant changes.

Conclusion

The bottom line for every development project is the productivity and marketability of the product. Android, powered by its OS, has certainly proven its marketability as major manufacturers begin manufacturing Android-powered smartphones, tablet computers, e-readers and other hand-held devices. devices. In fact, what seemed a disadvantage (Android applications being restricted to the Android platform) has become a blessing for the Android platform.

Android's open philosophy also ensures that any deficiencies in the user interface or native application design can be fixed by writing an extension or replacement. Android equips you with the tools to create mobile phone interfaces and applications that look, feel, and function exactly as you image them. However, developer productivity in Android is hampered by a slow emulator.

Qt on the other hand provides a highly productive development environment through the Qt Creator IDE. Since Qt is not devised for a particular OS, the marketability of Qt applications in the smartphone arena are heavily dependent on operating systems such as Symbian, MeeGo, and Maemo. However, Qt applications can be ported to Android devices, though it may take some time to attain technical maturity.

About the Author

Manoj Debnath is a Java programmer with more than seven years of software development experience.