Getting started with Qt
This article is for beginners who want to start development in Qt for Symbian. Before following the steps given here please make sure that Carbide.c++, S60 SDK and Qt for Symbian are properly installed.
- Install latest Qt for Symbian see Qt for Symbian - Installation packages
- Check this link for installation guide: How to install the package.
- 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...
Open the Carbide IDE and click File > New > Qt Project.
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.
Enter a name for the project and click Next.
Select the SDK to create the project for and click Next.
Select the module(s) and click Next. For our example, click Next without selecting any extra modules.
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 Symbian installed on your machine, choose the correct version as shown here:
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:
- Qt C++ Widget Box
- Qt C++ Property Editor
- Qt C++ Signal Slot Editor
- 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.
- Open Hello.ui.
- Open the Qt C++ Signal Slot Editor view.
- Click 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().
- In this example, we implement the Hello button event by coding in the files Hello.h and Hello.cpp.
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
#endif // HELLO_H
// 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
- 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.