×
Namespaces

Variants
Actions

Archived:How to create your first Qt application

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated. Note that this has the ArticleNeedsUpdate template. If the article is migrated to Qt Quick then it can be de-archived.

This article explains the basic steps to create a simple application using Qt. This article mainly aims at beginners and helps them create their very first application.

Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: deepikagohil (31 Mar 2010)
Last edited: hamishwillee (28 Jun 2012)

Needs-update.pngThis article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.

Reasons: hamishwillee (26 Aug 2011)
There are other articles on getting started with Qt. I think that we should ensure that there isn't more than one unless they provide a significantly different and valid approaches. So proposal is a review of articles on this topic on this wiki and merging where necessary. There should also be an update of links to the guidance in the library to point to other options like using Qt Quick and the Qt Components libraries for different platforms.

Whatever happens, it is also clear that this is out of date

  • Uses Qt Creator 1.3 - we're up to 2.x
  • Suggests Qt widgets, while most development would be best using Qt Quick for the UI
If this is updated with essentially same approach, then it should be renamed to "How create your first QWidget based application", and a clarification should be added that this is not the recommended approach.

(Note that this article also explains the initial steps, that is, installation steps before developing any Qt application.)

Contents

Introduction

Qt (pronounced "cute") is a cross-platform development and application framework. The programming language used in Qt is C++. So if you have basic knowledge of C++ you can start developing applications with Qt. And if you don't have the knowledge of Qt, you can learn C++ from the site given in the Reference section.

Applications made with Qt can be made to run on a desktop as well as on a mobile without modifying the source code, as it is a cross-platform application framework. Thus Qt provides flexibility and ease to the developer with a great efficiency in the application. There are also many more advantages of using Qt. To get more details, please visit A tour to the Qt (Qt).

Installation

If you want to develop applications with Qt, you need to download the Qt SDK for Windows. You can download it from Download Qt, the cross-platform application framework.

(Go to LGPL and download the Qt SDK as per your need. SDKs also includes the Qt Creator which is the IDE for developing applications with Qt.)

You can also visit Archived:Qt Tutorial Lesson 1 - Installation to get more detailed information about the installations.

Steps to Create a Qt GUI Application

  • After installing the Qt SDK, Open your Qt Creator 1.3 IDE.
  • Click on File -> New File or Project...
  • Choose Qt4 Gui Application.

Qtnewww1.jpg

  • Give a name to your application and then press Next.

Qtnewww2.jpg

  • Now press Next

Qtnewww3.jpg

  • Press Next

Qtnewww4.jpg

  • Press Finish.

Qtnewww5.jpg

Your application will have these much of folders and files:

  • Hello_Deepika.pro
  • mainwindow.ui
  • mainwindow.h
  • main.cpp
  • mainwindow.cpp

Foldersinproj.png

  • Hello_Deepika.pro is your project file. It keeps the information about your application.
  • mainwindow.ui is the file where your user interface (or you can say view) of your application will be created. Just click on this file, you will get the window of your application, here you can place the components from the list given on the left side of your IDE.

Qtwinbutton1.jpg

Here I have chosen a press button from the button's list and placed it on the application's window (though I have not handled the event generated by pressing the button yet...). This concept follows the "Signal and Slot" mechanism. You can refer to signal and slot related articles for the same in Signals and Slots, How to use Signals and Slot in Qt. You can do it in the .cpp file according to your logic.)

You can also read Creating a signal to slot connection in Qt Designer for a better understanding of signal and slot in Qt with images.

  • Now compile your application from the options given in the downside of the Qt Creator.

Compileappqt1.jpg

  • Build the application by right clicking on the application's name and then run it by doing the same.
  • You will get the output as shown in the figure below.

Runappqt1.jpg

That's it! You have created you first Qt application successfully!

References:

  • You can learn C++ at :

[1]

This page was last modified on 28 June 2012, at 09:25.
76 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.

×