Visual Design With Qt
Pages: 1, 2
Enter Qt Designer
Figure 1. The QT Designer "about" screen (click for larger view).
Qt Architect and QtEZ are certainly very good solutions, but Trolltech has long promised a GUI builder of their own, and they have finally delivered. The application needs the latest version of the Qt library: It makes use of the most advanced features, such as properties. Qt Designer can generate dialog windows, wizards, and general purpose widgets.
Besides the basic dropping of widgets on a canvas and setting their properties, Qt Architect offers the following features:
- Layout management
- Separate designer/user interface compiler
- Inclusion of third-party widgets
- Signals/slots connections
- Tab order editing
- Accelerator checking
- Fast preview
Figure 2. The QT Designer main interface (click for larger view).
Qt Designer's handling of layout management is especially clever. It hides a lot of the complexity of the mechanism by doing much of the work behind the scenes. For instance, margins are automatically added. This means of course that certain complex layouts can be difficult to achieve, at least more difficult than with Qt Architect. However, I find that the ease of use more than makes up for this lack of control, especially since the results of the automatic layout management are very pleasing aesthetically.
Figure 3. Qt Designer's handling of layout management is especially clever (click for larger view).
One very important design decision has been the separation of the designer tool and the user interface compiler, uic. In Qt Architect, the C++ generation code has been interwoven with the designer GUI, making it very difficult to replace the generator with one for another language. This decision also means that the .ui XML-file format is very sensible, which means that it can be handled with custom tools -- an important consideration in a corporate development environment.
As for third-party widgets, they are easy to include with Qt Designer. You don't need to enter any code, just to fill in the dialog shown in Figure 4.
Figure 4. Third-party widgets are easy to include (click for larger view).
The Qt signals/slots mechanism is supported in a very innovative manner. The developer simply draws a line from the signal-emitting widget to the signal-accepting widget. A box then pops up that shows all the relevant signals and slots, the developer selects the signal and the slot he wants to connect, and the connection is made!
People who have worked with Visual Basic know what an agony getting the tab order of the controls on a form just right can be -- there are a dozen third-party tools available, but it remains a finicky business. The Qt Designer solution is astonishingly simple: a small blue circle with a number is superimposed on all widgets, and the developer simply clicks on the widgets in the desired order. Likewise, the accelerator-checking option is extremely handy.
Figure 5. Setting the tab order of form controls (click for larger view).
Once a form has been created, it's very easy to preview the design in any of the supported styles (Motif, CDE, SGI, Windows, Platinum) -- there's no compilation needed, so the preview is instantaneous.
Another very important consideration is documentation. While I saw a pre-release copy, and the documentation wasn't finished yet, it was clear that the Qt Designer documentation is on the same level as the Qt library documentation. That means that it is well-written, in a fresh, engaging style, that it is complete, up-to-date and accurate. The documentation is written by Matthias Kalle Dalheimer, the author of the widely-acclaimed book "Programming with Qt".
Of course, there are some features missing, too. There's no real concept of a project -- every form is on its own, and there's no way to group related forms. This also means that it isn't possible to connect signals from one form to another. Qt Designer is capable of designing forms, wizards, and widgets, but it cannot design application windows. This means that there's no menu editor, nor a toolbar or status bar editor. But all these features are already planned for the second version.
The release of Qt Designer will invalidate one of the most serious objections to using Qt in commercial, large-scale development projects, namely that there is no professional, commercially supported GUI designer. Qt Designer is very stable, very easy to use and has some very innovative and very usable features. Importantly, the Qt Designer .ui file format is XML-based and has been sensibly designed: It will be easy to develop in-house tools to work with these files.
I've left the best for the last, though -- Reginald Stadlbauer, one of the Trolltech developers responsible for Qt Designer, assures me that Qt Designer will be included in the free edition of Qt, complete with sources. The definitive version will be released together with Qt 2.2, which is planned for August 2000.
Boudewijn Rempt is a senior developer with Tryllian, a mobile agent company. He has worked with PyQt since its inception.
Discuss this article in the O'Reilly Network Forum.
Return to the O'Reilly Network Hub.