15-07-2014, 02:52 PM
Get started with Qt GUI Programming
Get started with Qt.pdf (Size: 562.07 KB / Downloads: 33)
Introduction to Qt
Qt is a framework to create cross-platform applications. Using Qt
you can create amazing GUI applications quickly and fairly easily. You
might have heard about Visual Studio or X code to create applications in
Windows and Mac respectively...Qt is similar to these tools in that it helps
you to design and code your application. But, the real advantage of Qt lies
in the fact that your application can be made to run on a variety of
operating systems without you having to change your code. Your
application will run on Windows, Mac and Linux in pretty much the same
way. Talk about killing three birds with one bullet!
To get started with using Qt, you have to download it from
http://qt.nokiadownloads. You can go for the LGPL version or the
commercial version (both of them can be used to create proprietary
applications, if necessary) and choose a download for your OS.
Once you get the package installed, you get a number of Qt
developer tools at your disposal. Lets examine each one of th
My first application
That is the Welcome Screen which gives you quick links to your recent
projects or tutorials. We'll create a project by going to File>New file or
project. In the dialog, we select “Qt4 GUI Project”. Next they ask you to
name your project and the folder in which you want to store it in. I've
named my project “Example” for demonstration purposes. Next you will
be asked to select all the required modules for your project. The “QtCore”
and “QtGui” modules are already selected, and for our project, that is more
than enough. The other modules you can include later as and when you
need it.
Then, you are asked to enter basic information about your source
code files like, the base class name, form name etc. Its best to stick w
SIGNALS AND SLOTS
Signals and slots are the mechanism by which Qt achieves the unification
of GUI and code. It is both similar and very dissimilar to Java's Event
driven model. Each user interface component in Qt (Buttons, ListWidgets,
LineEdits, etc) can emit a wide variety of Signals (like clicked(),
triggered(), etc). These signals are then connected to Slots by the
programmer, which are nothing but methods or functions in the program.
So for example, we can connect the clicked() signal of a button to a Slot
(method) that does something when the button is clicked.
In our program, we will connect the textChanged() Signal with a Slot
called numberChanged(). To achieve this, let's check out the connect()
function: