|  | Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions |

# qt3to4 - The Qt 3 to 4 Porting Tool

The `qt3to4` tool provides help when moving a project from Qt 3 to Qt 4. It is designed to automate the most tedious part of the porting effort.

See the Porting Guide for more information about porting from Qt 3 to Qt 4.

## Usage

`qt3to4` can be run either on individual C++ source or header files, or on an entire project specified by a qmake `.pro` file:

        qt3to4 myfile.cpp
        qt3to4 myapp.pro

In project mode, `qt3to4` reads the `.pro` file and converts all files specified in it. The tool modifies the files in place. You might want to make a copy of your project before you run the tool.

## Porting Rules

The Qt porting tool loads its porting rules from an XML file called `q3porting.xml` located in Qt's `tools/porting/src` directory. By editing this file, you can add your own rules or remove some rules.

The standard `q3porting.xml` file specifies the following conversions:

- Rename classes that are now part of the Qt 3 support library (e.g., replace `QFileDialog` with `Q3FileDialog`).
- Prefix or rename enum values that have been moved or renamed (e.g., replace `QButton::On` with `QCheckBox::On`) or members of the Qt namespace (e.g., replace `QWidget::red` with `Qt::red`).
- Add `#include` directives that might be needed in Qt 4.
- Perform miscellaneous trivial changes (e.g., replace `TRUE` with `true`).

## Logging

The porting tool logs all changes to a file called `portinglog.txt` in the current directory. This file lists all changes made to the source files.

## State of the Porting Tool

The current version of the `qt3to4` tool is a beta version. It is intended to demonstrate how the finished program will work. You are encouraged to test it on your projects and report issues to us.

The following are known issues with this version that will be addressed in the next release:

- Scoping of names isn't handled correctly. This version of the Qt porting tool might change names which it shouldn't. For example, a user variable named `lightGray` will be changed to `Qt::lightGray`, because the tool doesn't parse user variable declarations yet.
- The `.pro` file isn't always updated to take into account the Qt library split. Since the Qt library has been split into several smaller libraries, a `QT` entry needs to be added to the `.pro` file depending on witch classes are used. The qt3support library is added if it's not already specified.
- Porting of designer `.ui` files is incomplete and might require some manual work.
- The `q3porting.xml` file isn't complete.