Qt GUI Toolkit

This GUI toolkit makes porting graphics to multiple platforms a snap.
Hints and Tips

If you are new to GUI programming, you might find that your first widget comes up blank on the screen or not at all. There are two very common reasons for this to happen.

First of all, a widget's window on the screen can be overwritten at any time by the window system. The window system does not store the contents for you, it just calls the widget's paint event function when the widget needs to be refreshed. Thus, if you draw on the widget but the paint event function doesn't reproduce the drawing exactly, you might not see any effect on the widget. Generally, the best method is to do all your drawing in the paint event function, and just instruct the widget to do a repaint whenever its state changes.

Secondly, when you create a widget, it is not visible. In Qt, you have to call the show member function to make widgets visible; other toolkits have a similar function.

Finally, I would like to mention a few points I consider important when designing and implementing GUI programs:

  • Keep it simple. When you build new widgets and dialogs try to keep their interfaces as small and elegant as possible. Don't add a lot of functions that might be nice to have in the future.

  • Don't crowd the screen. Try to keep your dialogs as intuitive and minimalistic as possible. A dialog should be both functional and pleasing to the eye.

  • Use double-buffering. At least when all or parts of a widget will change significantly over time. Programs that don't flicker look a lot more professional than the ones that do.

  • Cache like crazy. If there are parts of your program that do time-consuming operations, e.g., generation of pixmaps, save the result so that you don't have to do the same operations over and over.

  • Keep your member variables private—this is good object-oriented practice. In GUI programming it is even more important. A change in a variable often means that you have to update the screen. If you set variables via member functions, you can guarantee that the screen is always up-to-date.

  • Put your drawing code in one place—preferably in a single member function. Bugs in the relationship between the values in your member variables and what the widget displays are then located in one place. (You will be glad you did.)

  • Use standard types as arguments to signals and slots. If your signal contains an int, it can be connected to a large number of slots. If it contains an argument of the type MyNumber, the widget or dialog will not be as useful as a component.

Where to Find Qt

The Qt source and binary versions for several platforms (including Linux of course) can be downloaded from the net at ftp://ftp.troll.no/qt/.

Eirik Eng (iriken@troll.no) is a co-founder of Troll Tech AS, and works there as a developer. He has a siv.ing. (M.S.) degree from the Norwegian Institute of Technology and has worked with GUIs and OOP since 1991. His main hobby is office gardening (perfect for people who spend a lot of time at the office). This year he is especially proud of his 4 foot high (and still growing) eggplants and his tamarind tree.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

GUI deveopment using QT

Anonymous's picture

i wanted to know as to how a GUI can be developed using QT with C++ program give an example .

linux

sowmya's picture

sir,
i am troubling about qt.i am begineer of linux.In my project i am doing in linux.for gui designing we use qt design.i not very well about qt:gui design and where we write code in qt,and how to complie in c++ coding.i am using fedora.pls give me steps for designing and coding... i am waiting..

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions