Archived:Getting started with Qt
- Install Qt for S60 Temple release from here: Qt for S60 "Temple" pre-release
- 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 on File->New->Qt Project.
New window will open on the screen. This will show the type of the application one can create. Click on "Qt GUI Widget" and then click Next.
Give the name of the project and click on Next.
In this step one has to select the SDK for which the project is to be created and click Next.
In this window, click Next after selecting the module. For our example one has to click Next without selecting any extra modules.
Here, the class name is required. By default it is the application name. Click on Finish to proceed.
After finishing these steps, the project is ready. Several files will have been created automatically as shown in the screenshot below.
If you have more than one version of Qt for S60 installed on your machine then opt for the correct version as shown below.
Include Qt Views
- Include views for Qt from:
Carbide.c++ >> Windows >> Show View >> Other... >> Qt
- Select following views at minimal depending on the application:
- Qt C++ Widget Box
- Qt C++ Property Editor
- Qt C++ Signal Slot Editor
- Open Hello.ui and place the control from Qt C++ Widget Box
- We will add two push buttons and one text label in this article.
- 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 Qt C++ Signal Slot Editor view
- Click on to add entry for handling events on control
- In this article we will handle events on "Exit" push button
- The application will terminate when the user clicks on the "Exit" push button
- Here "exitButton" is the sender of the signal
- Here we will select "clicked()" signal to be sent by "exitButton"
- Here HelloClass is the receiver of this event handling mechanism.
- Here "Slot" is the action performed when "exitButton" will be "clicked()" and here we want to exit from the application therefore we will select "close()"
- We will implement Hello button event through coding in Hello.h and Hello.cpp files.
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 .pro file from the above extracted application in your Carbide.c++ IDE.
Carbide.c++ >> Import >> Qt >> Qt Project >> Hello.pro
- If you find any problem in creating your HelloWorld application in Qt, then please write your feedback in Comment page of this article. We will try to help you at our best.