March 3, 2021
Hot Topics:

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

  • By Manoj Debnath
  • Send Email »
  • More Articles »

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.

Android applications start from an Activity instance. This code snippet demonstrates the basic idea.

package org.mypackage.mynamespace;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Androidproj2Activity extends Activity {
public void onCreate(Bundle savedInstanceState) {
TextView textView=new TextView(this);
textView.setText("Hello World");

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.

import Qt 4.7
Rectangle {
Width : 270
Height : 170
Text {
anchors . horizontalCentre : parent . horizontalCenter
anchors . verticalCenter : parent . verticalCenter
text : "Hello World"

The basic entry point for the Qt mobile platform is the main method. Here is a sample starting point for a widget-based mobile application.

#include "mainwindow.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
QApplication app(argc, argv);
MainWindow mainWindow;
return app.exec();

Page 1 of 2

This article was originally published on February 18, 2012

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date