Installation of Qt in Ubuntu (11.10 onward)
 
Qt requires g++ for program compilation. Make sure that g++ is installed before installing Qt. Refer to install-ubuntu for information.

The easiest way to install Qt in Ubuntu is as follows:

   sudo apt-get install libqt4-dev

This will install Qt 4 in your Ubuntu system.

If you like to install the latest version of Qt, try the following method.

Download Qt installation package from Qt home page, e.g., "QtSdk-online-linux-x86_64-v1.2.1.run". Then, go to the directory that contains the package and issue the commands:

   chmod u+x QtSdk-online-linux-x86_64-v1.2.1.run
   sudo ./QtSdk-online-linux-x86_64-v1.2.1.run


By default, Qt is installed in /opt/QtSDK.

After installing Qt, add the path where qmake resides into your command search path PATH:

   PATH=$PATH:/opt/QtSDK/Desktop/Qt/4.8.0/gcc/bin

Qt can make use of OpenGL for graphics rendering. To do that, need to install OpenGL.
 
Compiling Qt Programs
 
The most convenient way to compile Qt programs is to use qmake as follows.

In the directory that contains the .cpp files, run

   qmake -project

to create a .pro project file. You may need to edit the .pro file if certain include paths or library paths are missing. Next, run

   qmake
   make

The first command invokes qmake to create the makefile which make uses to compile the program.

For more information about qmake and its support for Qt, refer to the online qmake manual.
 
Compiling Qt and VTK Programs
 
To use VTK with Qt, first install VTK with Qt support.

One easy way to compile both Qt and VTK programs is to add the required VTK header files and library files into Qt project file.

(1) Create a separate Qt project file, say vtk.pro, to keep the required VTK header files and library files:

   QMAKE_CXXFLAGS += -Wno-deprecated
   INCLUDEPATH += /usr/local/include/vtk
   LIBS += -L/usr/local/lib/vtk -lQVTK -lvtkIO -lvtkCommon -lvtkViews -lvtkWidgets -lvtksys \
           -ldl -lGL -Wl


     The first line tells the compiler not to display warning messages for use of deprecated C++ functions by VTK.
     The second line includes the directory of VTK header files. The third line adds the required VTK library files.

(2) Run "qmake -project" to generate the application's project file, say myapp.pro.

(3) In the application's project file myapp.pro, add the following line before the HEADERS list:

   include(vtk.pro)

(4) Run "qmake" to generate the Makefile. This Makefile will include the VTK header directory and library files.

(5) Run "make" to compile and link the programs.
 
Troubleshooting
 
Gtk-Warning: Unable to locate theme engine in module_path: "pixmap"

This problem may occur when you run qtdemo, which is probably using GTK. To fix this problem, install the gtk2-engines-pixbuf package:

      sudo apt-get install gtk2-engines-pixbuf
 
Documentation
 
For online documentation, browse Qt Developer Network's documentation.

For offline documentation of Qt, run the Qt Assistant

   assistant

If Qt Assistant is not already installed, you can install it using Ubuntu Software Center or apt-get:

   sudo apt-get install qt4-doc
or
   sudo apt-get install qt4-dev-tools
 
Qt Development Tools
 
Qt comes with design and development tools that can be easily installed from Ubuntu Software Center:
> Qt Designer: interface design
> Qt Creator: integrated development environment
> Qt Linguist: translation tool
> Qt Settings: Qt configuration tool