Archived:Porting iPhone native (Objective-C) applications to Qt for Symbian

From Qt Wiki
Jump to navigation Jump to search

Template:Archived Template:ArticleMetaData

Introduction[edit | edit source]

When someone familiar with developing for iPhone (Mac Os) Os moves to developing for Symbian OS, there is a period of uncertainty about where to start. Objective-c is used for the native application development in iPhone while in Symbian OS Symbian c++ is used for this purpose. Qt is now becoming a popular among the mobile

developer because of its easy syntax and cross platform capability. Application development using Qt is capable of running on various platform like Windows, Mac-OS, Linux, Symbian. While objective-c application can not provide such a liberty.


This article is meant to provide beginning and intermediate objective-c developers with an introduction to porting applications from objective-c to Qt.

File:Iphone.JPGFile:Nokia-n97-2.jpg

Overview of Objective-c and Qt architecture[edit | edit source]

iPhone objective-c application based on the architecture given below.

File:IPhone Arc.jpg


Qt Architecture Overview

File:Qtarchitecture.jpg

File:Qts60.jpg

Languages Used for Native Development[edit | edit source]

iPhone OS: Objective-C

Symbian OS: Symbian C++,Qt


Tools[edit | edit source]

Qt Objective-C
IDE Carbide C++,Qt creator XCode

Organization Of Source Code[edit | edit source]

Extension Objective-c Extension Qt
.h Header file .h Header file
.m Source file .cpp/.c Source file
.mm Source files(if actually refer to C++ classes or features from your Objective-C code) .cpp Source file

main() function comparison[edit | edit source]

Objective-C main() function[edit | edit source]

  1. import <UIKit/UIKit.h>

int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; }

Here actual user code is written in the UIApplicationMain function which is called as soon as application loading is completed.

Qt main() function[edit | edit source]

  1. include <QApplication>
  1. include "digitalclock.h"

int main(int argc, char *argv[]) {

   QApplication app(argc, argv);
   DigitalClock clock;
   clock.showMaximized();
   return app.exec();

}

Here user code is written in a separate .cpp file or can be written in the main file also.

Main difference : Qt uses a #include while objective-c uses a #import.