Wednesday, January 25, 2012

HelloWorld Qt App Explained part 1 of 2

While back I have created a video which explains the code behind HelloWorld app for Nokia Symbian^3 phones.  I have decided to write a post about the video. In this post I will also provide the source code from the files covered in the video.

This post (and video featured in it) is 2nd part of 3 part whole. You should read first article before reading this one.You can find it here:
Hello World for Symbian^3 with Qt Quick components done using Qt Creator 

After you finished with this article you should watch part 3. You can find it here:
HelloWorld Qt App Explained part 2 of 2

In the video tutorial I will explain native code and project file of the Qt Hello World app for Symbian^3 phones.
Covered in this episode:
- project file explained: symbian:TARGET.CAPABILITY, CONFIG and SOURCES
- main.cpp file (also called native code): QApplication, QmlApplicationViewer
- using help




Here is my the video:



This code is tested on Symbian Anna and Belle phones. This code was written using QtSDK 1.4.4. and Qt Creator 2.4.0 Based on Qt 4.7.4 (32 bit) Built on Dec 16 2011 at 03:25:42. At the moment of writing this text it was latest version of QtSDK available. With newer versions of Qt the code will probably change and it will get updated. If the code changes the logic behind is will stay the same so this video will be of some use to you.

Aditional liks:
Learn more about Project file CONFIG and SOURCES:
http://developer.qt.nokia.com/doc/qt-4.8/qmake-project-files.html
Learn more about Capabilities
http://www.developer.nokia.com/Community/Wiki/Capabilities
Learn more about QApplication
http://developer.qt.nokia.com/doc/qt-4.8/QApplication.html

Qt Fundamentals (1/2) explains return app.exec(); line from main.cpp I didn't cover.
http://developer.qt.nokia.com/videos/watch/qt_essentials_widget_edition_fundamentals_of_qt_part_1_your_first_qt_applic


Here is the source code covered in this video
HelloWorld.pro Project file looks like this:

# Add more folders to ship with the application, here
folder_01.source = qml/HelloWorld
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =

symbian:TARGET.UID3 = 0xE6B757F6

# Smart Installer package's UID
# This UID is from the protected range and therefore the package will
# fail to install if self-signed. By default qmake uses the unprotected
# range value if unprotected UID is defined for the application and
# 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF

# Allow network access on Symbian
#symbian:TARGET.CAPABILITY += NetworkServices

# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=

# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
# CONFIG += qdeclarative-boostable

# Add dependency to Symbian components
CONFIG += qt-components

# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp

# Please do not modify the following two lines. Required for deployment.
include(qmlapplicationviewer/qmlapplicationviewer.pri)
qtcAddDeployment()


main.cpp file looks like this:
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    QmlApplicationViewer viewer;
    viewer.setMainQmlFile(QLatin1String("qml/HelloWorld/main.qml"));
    viewer.showExpanded();

    return app->exec();
}

No comments:

Post a Comment