(Difference between revisions)

Archived:Getting started with Qt

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
(Undo revision 45288 by Mind freak (Talk))
jimgilmour1 (Talk | contribs)
m (remove reference to Qt s60 sdk garden)
Line 18: Line 18:
== New Release ==
* Install Qt for S60 Garden pre-release from here: [http://pepper.troll.no/s60prereleases/ Qt for S60 "Garden" pre-release] and is release Qt 4.5 as of 10-March-09
* See [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package] for the installation guide.
== Prerequisite==
* Install latest Qt for S60 see [http://wiki.forum.nokia.com/index.php/Qt_for_S60_-_Installation_packages Qt for S60 - Installation packages]
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package].
* Go through this article: [[Getting started with Qt for S60]]
== Prerequisite==
* Carbide.c++ 2.0 does not automatically locate your Qt installation, so you need to tell it where Qt is installed. This is done through the following settings:  
* Carbide.c++ 2.0 does not automatically locate your Qt installation, so you need to tell it where Qt is installed. This is done through the following settings:  
   '''Carbide.c++ preferences: Window > Preferences > Qt > Add...'''
   '''Carbide.c++ preferences: Window > Preferences > Qt > Add...'''

Revision as of 14:34, 29 June 2009

Featured Article
Article Metadata
Tested with
Devices(s): Emulator
Platform(s): S60 3rd Edition, S60 5th Edition
Keywords: PushButton, TextLabel, Signal and Slot
Created: (29 Dec 2008)
Last edited: jimgilmour1 (29 Jun 2009)



This article is for beginners who want to start development in Qt for S60. Before following the steps given here please make sure that Carbide.c++, S60 SDK and Qt for S60 are properly installed.


  • Carbide.c++ 2.0 does not automatically locate your Qt installation, so you need to tell it where Qt is installed. This is done through the following settings:
  Carbide.c++ preferences: Window > Preferences > Qt > Add...

Qt Preference.PNG

First Step

Open the Carbide IDE and click File > New > Qt Project.


Second Step

A new window will open on the screen. This will show the application types that can be created. Click Qt GUI Widget and then click Next.


Third Step

Enter a name for the project and click Next.


Fourth Step

Select the SDK to create the project for and click Next.


Fifth Step

Select the module(s) and click Next. For our example, click Next without selecting any extra modules.


Sixth Step

The class name is required. By default it is the application name. Click Finish to proceed.


After finishing these steps, the project is ready. Several files are created automatically as shown in the following screenshot.


If you have more than one version of Qt for S60 installed on your machine, choose the correct version as shown here:


Error creating thumbnail: Image type not supported

Include Qt Views

  • Include views for Qt from:
  Carbide.c++ > Windows > Show View > Other... > Qt


  • View selection depends on the application. However, at least the following views must be selected:
  1. Qt C++ Widget Box
  2. Qt C++ Property Editor
  3. Qt C++ Signal Slot Editor

Adding controls

  • Open Hello.ui and place the control from the Qt C++ Widget Box.


  • In this example, two push buttons and one text label will be added.
  • The display text of an object can be changed by right clicking on object > Change text...
  • The name of an object can be changed as shown in the following screenshots.

Text label


Hello push button


Exit push button


Implementing Signal and Slot mechanism for Exit push button

  • Open Hello.ui.
  • Open the Qt C++ Signal Slot Editor view.


  • Click QtSignalPlus.png to add an entry for handling events on control.
  • In this example, we will handle events on the Exit push button
  • The application will terminate when the user clicks the Exit push button


  • exitButton is the sender of the signal.



  • Select the signal clicked() to be sent by exitButton.



  • HelloClass is the receiver of this event handling mechanism.



  • Slot is the action performed when exitButton is clicked(). To exit from the application, select close().


Implementing the Hello push button

  • In this example, we implement the Hello button event by coding in the files Hello.h and Hello.cpp.

Header file

#ifndef HELLO_H
#define HELLO_H
#include <QtGui/QWidget>
#include "ui_Hello.h"
class Hello : public QWidget
Hello(QWidget *parent = 0);
public slots: //We have added this section to handle "clicked()" event on "helloButton"
void ShowHelloText(); // Fill the label text on clicking "Hello" button
Ui::HelloClass ui;
#endif // HELLO_H

Source file

#include "Hello.h"
Hello::Hello(QWidget *parent)
: QWidget(parent)
// Signal and slot mechanism for "helloButton"
QObject::connect(ui.helloButton, SIGNAL(clicked()), this, SLOT(ShowHelloText()));
//We have implemented the following function to display "HelloWorld!!!" text in TextLabel
void Hello::ShowHelloText()


Initial state


Hello button pressed state


Example application

  • Extract this example application: Hello.zip
  • Import the .pro file from the previously extracted application in your Carbide.c++ IDE.
  Carbide.c++ >> Import >> Qt >> Qt Project >> Hello.pro


  • If you encounter any problems in creating your HelloWorld application in Qt, please enter your feedback in the Comment page of this article.
472 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.