and the Qt Overview listed in the
Resources section for more information.
Qt Assistant, discussed later in this
article, also has an excellent tutorial.

Adding Your Own Code

Other Qt4 tutorials become code-heavy
at this point and lose people who are
not experienced C++ programmers.
Here, I explain how to link your code
to the GUI interface in a simple and
pain-free manner with minimal C++.

Adding code to a GUI project is not
like writing code for a command-line
program. Your code must be placed in
the class created for you, in the example
demo_1.cpp, not a main() routine.
You should alter only demo_1.cpp,
demo_1.h or demo_1.ui. The other files
are generated automatically and will be
overwritten on the next build.

Your code can be started only when
a GUI event happens and it is linked to
your code, or when a timer you have
created times out. Furthermore, your
code must do its job quickly and return.
If your code delays, the entire application freezes and stops responding to
user stimuli. These factors require you to
design your code differently from how
you would design a command-line program. When you write a GUI program,
plan for all of your code to respond to
GUI events and timers. The GUI package
handles the rest for you.

Most GUI systems have a library ofuseful classes, and it’s very much worthlearning how to use those classes, asthey can save you a lot of time and pro-vide features you could not implementotherwise. The library with Qt Designeris particularly powerful and worthmastering (more on that later).