Home · Tutorial · Classes · Functions · Language · QSA Workbench · Qt Documentation · www.trolltech.com

QSA Extension Frameworks

QSA Input Dialog Framework

The QSA Input Dialog Framework is a set of classes that extends QSA to enable the user to create dialogs using Qt Script. The Input Dialog Framework is available in the QSObjectFactory subclass QSInputDialogFactory.

The QSA Input Dialog Framework provides two types of classes. The first types are the ones that can be used to build up complex input dialogs. These classes include, Dialog, CheckBox, GroupBox, LineEdit, TextEdit, etc. These classes each have a set of properties for describing how they appear and some of them also provide functions.

The following is a simple example on how to use the Input Dialog Framework to create a dialog that will query the user for their first and last name, and echo the values they entered:

    
    var dialog = new Dialog;
    dialog.caption = "Name reading dialog";
    dialog.okButtonText = "Done"
    dialog.cancelButtonText = "Abort";
    
    var first = new LineEdit;
    first.label = "First name: ";
    dialog.add( first );
    
    var last = new LineEdit;
    last.label = "Last name: ";
    dialog.add( last );
    
    if( dialog.exec() ) {
        var fullName = last.text + ", " + first.text;
        print( "Full name is: " + fullName );
    }

Below is a list of the classes available from the Input Dialog Framework. Each class has a short description and a list of its properties and functions.

For String properties the default is an empty string, and for Number properties the default is 0, unless stated otherwise.

CheckBox

The CheckBox widget provides a checkbox with a text label. CheckBox is an option button; it can be switched on (checked) or off (unchecked).

Properties

ComboBox

The ComboBox widget is a combined button and drop-down list. A combobox is a selection widget which displays the current item and can drop down a list of items. A combobox may be editable in which case the user can enter arbitrary strings.

Properties

DateEdit

The DateEdit class provides a date editor. DateEdit allows the user to edit dates by using the keyboard or the arrow keys to increase/decrease date values. The arrow keys can be used to move from section to section within the DateEdit box. Dates appear in accordance with the local date/time settings or in year, month, day order if the system doesn't provide a local date order.

Properties

Dialog

The Dialog class is the base class of dialog windows. A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user. Dialogs may be modal or modeless.

Properties

Functions

GroupBox

The GroupBox widget provides a group box frame with a title and can displays other widgets inside itself.

Properties

Functions

LineEdit

The QLineEdit widget is a single-line text editor.

Properties

NumberEdit

The NumberEdit class provides range checking of floating-point numbers. NumberEdit provides an upper bound, a lower bound and a limit on the number of digits after the decimal point.

Properties

RadioButton

The RadioButton widget provides a radio button with a text label. RadioButton is an option button; it can be switched on (checked) or off (unchecked). Sets of Radio buttons grouped together (for example in a GroupBox), are mutually exclusive.

Properties

SpinBox

The SpinBox class provides a spin box widget (spin button). SpinBox allows the user to choose an integer value either by clicking the up/down buttons to increase/decrease the value currently displayed or by typing the value directly into the spin box. If the value is entered directly into the spin box, Enter (or Return) must be pressed to apply the new value.

Properties

TextEdit

The QTextEdit widget provides a multi-line text editor.

Properties

TimeEdit

The TimeEdit class provides a time editor. TimeEdit allows the user to edit times by using the keyboard or the arrow keys to increase/decrease time values. The arrow keys can be used to move from section to section within the TimeEdit box.

Properties

Convenience Classes

The convenience classes provide static functions to obtain a value from the user without using any complex widget hierarchies. Because the functions are static they can be called directly without the need to create an instance of the class. For example, to get a filename all that is necessary is to call FileDialog.getOpenFileName().

The MessageBox class

This class provides a simple way of popping up a message box window for the user. The following lines of code present a pop up messagebox with a warning and query the user to click Yes or No.

    
    var ans = MessageBox.warning( "Do you wish to save the data?", MessageBox.Yes, MessageBox.No );
    if (ans == MessageBox.Yes) {
        save();
    }

Button types

The button types are used to describe what the text of the buttons should be. The following are available.

Functions

The following is a list of message box functions. The button1, button2 and button3 parameters can be any of the Button types described above and specify which button types will be shown in the message box. Each function returns the button type that the user pressed.

The FileDialog class

This class provides dialogs that allow users to select files or directories. The following function call will open a file dialog with that will display files with the extension .txt.

    
    var filename = FileDialog.getOpenFileName( "*.txt" );
    if (filename) {
        processfile(filename);
    }

Functions

The Input class

This class provides convenience functions for getting simple input from the user. The following code can be used to open a dialog that queries the user for a text:

    
    var name = Input.getText( "What is your surname? " );
    if (name) {
        processname(name);
    }

Functions

QSA Utility Framework

The QSA Utility Framework is a set of classes that extends QSA to enable the user to read and write files, access directory structures and start processes synchronously and asynchronously. The Utility Framework is available in the QSObjectFactory subclass QSUtilFactory

File Class Reference

The File class provides functionallity for reading and writing binary and text files. A File can be instantiated as an object, giving the scripter complete flexibility when reading and writing files. In addition, the File class provides a set of static convenence functions for reading and writing files in one go.

Typical use of a File is:

    
    // Reads an entire file in one go

    var log = File.read('file.log');
    // Writes an entire file in one go

    File.write('copy_of_file.log', log);
    
    // Read and write a file line by line

    var infile = new File('file.log');
    infile.open(File.ReadOnly);
    
    var outfile = new File('copy_of_file.log');
    outfile.open(File.WriteOnly);
    
    while (!infile.eof) {
        var line = infile.readLine();
        outfile.write( line );
    }
    
    infile.close();
    outfile.close();

Enums

AccessMode

The enum AccessMode is used in conjunction with File.open to specify the mode in which the file is opened.

Static Functions

Constructor

Properties

The File object's properties are read-only.

Member Functions

Dir Class Reference

The Dir class provides access to directory structures and their contents in a platform-independent way. It provides a means of listing directory content, creating filenames with proper path separators, etc.

An example use of the Dir class is:

    
    var dir = new Dir;
    var codeFiles = dir.entryList('*.cpp');
    for (var i = 0; i < codeFiles.length; ++i) 
        print(codeFiles[i]);

Enums

FilterSpec

This enum describes the filtering options available to Dir for entryList(). The filter value is specified by OR-ing together values from the following list.

SortSpec

This enum describes the sort options available to Dir for entryList(). The sort value is specified by OR-ing together values from the following list:

Static Properties

Static Functions

Qt uses "/" as a directory separator throughout (although it understands the conventions of the platform it is used on). If you are working with paths, use "/" within your code, and use convertSeparators() when you want to display a path to the user.

Constructor

Properties

Member Functions

Process Class Reference

The Process class is used to start external programs and to communicate with them. The Process class can start programs synchronously using Process.execute(), and asynchronously using new Process(...).start().

Static Properties

Static Functions

Constructor

Properties

Member Functions


Copyright © 2006 Trolltech Trademarks
QSA 1.2.2