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

Brief Technical FAQ

This document describes how to use more than one TQt version on one machine and how to use TQt on X11 without a window manager. In addition it explains the most common source of link errors with TQt.

Other frequently asked questions can be found in the FAQ index and in the Technical FAQ.

Link error, complaining about a lack of vtbl, _vtbl, __vtbl or similar

This indicates that you've included the TQ_OBJECT macro in a class declaration and probably also run the moc, but forgot to link the moc-generated object code into your executable. See Using the Meta Object Compiler for details on how to use moc.

Using different versions of TQt on the same machine

TQt programs need the following components of a TQt distribution:

Header files - Compile time

Programmers need to include the TQt header files. The TQt header files are usually located in the include subdirectory of TQt distributions. Care must be taken to include the header files of the relevant release of TQt. Those with a command-line compiler will typically use options such as /I%QTDIR%\include the relevant release of TQt.

Meta Object Compiler and other tools - Compile time

Programmers need to run moc and other tools such as uic. These tools are usually located in the bin subdirectory of TQt distributions. Either run "$QTDIR"/bin/moc and "$QTDIR"/bin/uic or add "$QTDIR"/bin to your PATH and run moc and uic. If you use qmake the appropriate lines will be added to your Makefiles so that uic and moc will be executed as required.

Static or shared libraries - Link time

Programmers need to link with the TQt static or shared libraries. The TQt libraries are usually located in the lib subdirectory of TQt distributions. Care must be taken to link with the libraries of the relevant release of TQt. Those with a command-line compiler will typically use options such as /L%QTDIR%\lib\qt.lib or -L"$QTDIR"/lib -lqt provided QTDIR specifies the relevant release of TQt.

Shared libraries - Run time

Users of programs linked with shared TQt libraries need these same shared libraries to run these programs. The TQt libraries are usually located in the lib subdirectory of TQt distributions. Shared libraries are made available to programs in places such as C:\windows\system on Windows platforms, directories listed in file /etc/ld.so.conf on Linux, standard lib directories on Unix, or directories listed in environment variables LD_LIBRARY_PATH, SHLIB_PATH, or LIBPATH on various Unix flavours. Make the relevant TQt libraries available using one of these mechanisms.

TQt distributions consist of different files needed at compile time, link time, or run time. Trolltech distributes TQt in the form of a source package that contain all these files once they have been built.

Other vendors distribute TQt in the form of binary packages. Binary packages usually consist of two parts:

Depending on how you are using TQt, you need to make specific parts of the TQt distribution available to your programs. Typical situations are described below.

Developers building for a single version of TQt on Unix - TQt binary packages

You build programs with a single version of TQt, but you still need to run programs linked with another version of TQt. You are typically a Linux developer who builds programs for TQt 3.x on a KDE desktop based on TQt 2.x. TQt packages are usually split into a shared library package with a name like qt and a developer package with a name like qt-dev. You will need the appropriate packages:

Just install the packages, qt2, qt3, and qt3-dev. You may need to set the environment variable QTDIR to point to TQt 3.x.

Developers building for two versions of TQt on Unix - TQt sources

You build and run programs for TQt 2.x and TQt 3.x. You will need:

Get the source distributions of both TQt 2.x and TQt 3.x.

  1. Install and build TQt 2.x and TQt 3.x, usually in /opt or /usr/local. In the case of /opt:

    $ cd /opt
    $ gunzip -c \c qt-x11-2.3.1.tar.gz | tar xf -
    $ cd qt-2.3.1
    $ setenv QTDIR /opt/qt-2.3.1
    $ configure [options]
    $ make
    
    $ cd /opt
    $ gunzip -c qt-x11-free-3.0.0.tar.gz | tar xf -
    $ cd qt-3.0.0
    $ setenv QTDIR /opt/qt-3.0.0
    $ configure [options]
    $ make
    

  2. Make shared libraries available to programs at run time. Either add both /opt/qt-2.3.1/lib and /opt/qt-3.0.0/lib to your environment variable LD_LIBRARY_PATH or file /etc/ld.so.conf or whataver mechanism you're using, or make links to the libraries in a standard directory like /usr/local/lib:

    cd /usr/local/lib
    ln -s /opt/qt-2.3.1/lib/libtqt.so.2 .
    ln -s /opt/qt-2.3.1/lib/libtqt-mt.so.2 .
    ln -s /opt/qt-2.3.1/lib/libqutil.so.1 .
    ln -s /opt/qt-3.0.0/lib/libtqt.so.3 .
    ln -s /opt/qt-3.0.0/lib/libtqui.so.1 .
    

To develop with TQt 2.x use:

setenv QTDIR /opt/qt-2.3.1
setenv PATH ${QTDIR}/bin:${PATH}

To develop with TQt 3.x use:

setenv QTDIR /opt/qt-3.0.0
setenv PATH ${QTDIR}/bin:${PATH}

Setting QTDIR ensures that the proper resources are used, such as the documentation appropriate to the version of TQt you're using. Also your Makfiles may refer to "$QTDIR"/include and "$QTDIR"/lib to include the proper header files and link with the proper libraries. Setting the PATH ensures that the proper version of moc and other tools is being used.

Using TQt on X11 without a window manager

When using TQt without a window manager on Unix/X11, you will most likely experience focus problems. Without a window manager, there is no focus handling on X11, and no concept of an active window either. If you want your application to work in such an environment, you have to explicitly mark a window as active after showing it:

 yourWindow->show();
 yourWindow->setActiveWindow();

Note that setActiveWindow() won't work if the widget does not become physically visible during this event cycle. However, without a window manager running, this is guaranteed to happen. For the curious reader: setActiveWindow() emulates a window manager by explicitly setting the X Input Focus to a widget's top level window.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8