Archived:How to create your first Qt application
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.
(Note that this article also explains the initial steps, that is, installation steps before developing any Qt application.)
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).
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.
- Give a name to your application and then press Next.
- Now press Next
- Press Next
- Press Finish.
Your application will have these much of folders and files:
- 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.
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.
- 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.
That's it! You have created you first Qt application successfully!
- You can learn C++ at :