[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.11.7 Using QT Designer To Create AWS Definition Files

On many platforms Trolltechs Designer is available, a tool that lets you create graphical user interfaces like Dialogs, Forms etc. It saves the interface description in an easy to read format (XML - even though i was not able to locate a formal document type description (DTD) for it, it's format is pretty obvious).

You should be aware that not all features the Designer is capable of can be translated into AWS simply because they are not available in AWS. The same is true for features available in AWS but not in Designer.

What you need

Since Designer saves its interface description in XML writing an extensible stylesheet to transform it into AWS format was an obvious choice. So you will need a XSLT stylesheet processor. You can either choose a commercial product or the excellent Xalan which is part of the Apache project. You can get it for free here: http://xml.apache.org For development i used the Xalan Java 2 version at: http://xml.apache.org/xalan-j/index.html

How to use it

Design your dialog or widget in Designer and save it somewhere. To process the stylesheet with the java version of Xalan you call:
 
java org.apache.xalan.xslt.Process \
    -IN path/to/the/saved/designer/file.ui \
    -XSL path/to/CS/scripts/aws/qt2aws.xsl

If you use Designer 1.1 (that comes with QT2) you use qt2aws.xsl. The new Designer version 2.0 (which comes with QT3) changed it's .ui DTD slightly. In case you use Designer2.0 use qt3aws.xsl.

Append the output to a file containing skin definitions.

What controls are converted ?

QT Class AWS Class
QPushButton ==> Command Button
QRadioButton ==> Radio Button
QSlider ==> Scroll Bar
QButtonGroup ==> Group Frame
QGroupBox ==> Group Frame
QFrame ==> Group Frame
QCheckBox ==> Check Box
QLineEdit ==> Text Box
QTextView ==> Multiline Edit
QLabel ==> Label
QLabel with Pixmap ==> Image View
QListBox ==> List Box
QListView ==> List Box
QDialog ==> Window
QWidget ==> Window
QTabWidget ==> Notebook

Special Notes

AWS Signals and special properties

You can place special information in the controls whatsThis property. The content will be broken into tokens separated by the pipe ("|"). A token consist of a token identifier, the colon : and token text. The following tokens are recognized:

Both examples from above would be concatenated and placed in the whatsThis property and would look like this:

 
c:signalClicked,mySink::OnClick,signalBreak,
    mySink::ByeBye|l:LeftEye: "Blue"

How to handle your own AWS controls

If you coded your own AWS control you can still use QT to layout the control (at least the common parameters like size and position). For this to work simply choose one of the supported controls and use it as a placeholder. Additionally you use the token identifier 't' in the whatsThis property of that control to name of your control class.

Example:

I have created my own push button control. The name of the control class is awsMyFancyPushButtonControl. Since it uses all the properties of the standard AWS command button i cleverly use the QPushButton as my placeholder and set all the properties i need and QPushButton already offers like size, position, button text and others. Additionally i set the t token identifier in property whatsThis to awsMyFancyPushButtonControl.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html