# Qt Script Qt Bindings Reference Documentation

### Packages

- com.trolltech.qt.core
- com.trolltech.qt.gui
- com.trolltech.qt.network
- com.trolltech.qt.opengl
- com.trolltech.qt.phonon
- com.trolltech.qt.sql
- com.trolltech.qt.svg
- com.trolltech.qt.uitools
- com.trolltech.qt.webkit
- com.trolltech.qt.xml
- com.trolltech.qt.xmlpatterns

### All Classes

### Examples

### Getting Started

Using the Qt API in Qt Script is very similar to C++.

    var f = new QFile("foo.txt");

C++ enum values are mapped to properties of the script constructor function; e.g. QIODevice::ReadOnly becomes QIODevice.ReadOnly.

    f.open(new QIODevice.OpenMode(QIODevice.ReadOnly));

Each C++ flag type is mapped to a property of the script constructor function; e.g. QIODevice::OpenMode becomes QIODevice.OpenMode. Such a property is a constructor function that takes one or more enum values and constructs a flags instance by OR'ing the arguments together.

    var ts = new QTextStream(f);
    ts.writeString("Boo");

C++ streaming operators are normally mapped to readT() and writeT() functions.

    f.close();

In Qt Script, all objects are allocated on the heap; objects that are no longer referenced are garbage collected sometime in the future; therefore, make sure to explicitly free up resources if you can. (Without the call to close(), the underlying file would remain open until the file object is garbage collected.)

### Qt Reference Documentation