Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

Common Problems


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

This indicates that you include the Q_OBJECT macro in a class declaration and probably also run the moc, but forget to link the moc-generated object code into your executable. Read Using the Meta Object Compiler for details on how to use moc.

Using different versions of Qt on the same machine

Qt programs need the following components of the Qt distribution:

Header files - Compile time

Programmers need to include the Qt header files. Those with a command-line compiler will typically use options such as /I%QTDIR%\include or -I${QTDIR}/include. They will need the header files of the version of Qt they wish to build programs with. The header files are in the include subdirectory of Qt distributions.

Meta Object Compiler - Compile time

Programmers need to run the Meta Object Compiler - moc. The moc is found in the bin subdirectory of Qt distributions.

Static or shared libraries - Link time

Programmers need to link with static or shared libraries. Those with a command-line compiler will typically use options such as /L%QTDIR%\lib\qt.lib or -L${QTDIR}/lib -lqt. They will need the libraries of the version of Qt they wish to build programs with. The libraries are in the lib subdirectory of Qt distributions.

Shared libraries - Run time

Users of programs built with the shared Qt libraries need these same shared libraries to run the programs. The libraries are in the lib subdirectory of Qt 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 the directories listed in the environment variable ${LD_LIBRARY_PATH} on Unix/Linux.

Binary packages usually consist of two parts:

  • run time libraries in the run time package, usually called qt2.
  • header files, the moc and static libraries in the developers' kit, usually called qt2-dev.

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

Developers building for a single version of Qt on Unix - Qt packages

You build programs with a single version of Qt, but you still need to run programs linked with another version of Qt. You are typically a Linux developer who builds programs for Qt 2.x on a KDE desktop based on Qt 1.4x. Qt 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:

  • To build programs you will need the header files, the moc and the libraries of Qt 2.x. They are included in the developer package of Qt 2.x (qt2-dev or the like).
  • To run programs you will need the shared libraries of Qt 2.x and Qt 1.4x. They are included in the regular packages of Qt 2.x (qt2 or the like) and Qt 1.4x (qt1 or the like).

Just install those 3 packages. You may need to set the environment variable QTDIR.

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

You build and run programs for Qt v1.4x and Qt 2.x. You will need:
  • the header files, the moc and the libraries of Qt 2.x and Qt 1.4x to build programs,
  • the shared libraries of Qt 2.x and Qt 1.4x to run programs (if you use shared linking).

Get source distributions of both Qt 1.4x and Qt 2.x.

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

    $ cd /opt
    $ gunzip -c qt-1.44.tar.gz | tar xf -
    $ cd qt-1.44
    $ setenv QTDIR /opt/qt-1.44
    $ configure [options]
    $ make
    
    $ cd /opt
    $ gunzip -c qt-2.1.0.tar.gz | tar xf -
    $ cd qt-2.1.0
    $ setenv QTDIR /opt/qt-2.1.0
    $ configure [options]
    $ make
    
  2. Make shared libraries available to programs at run time. Either add both /opt/qt-1.44 and /opt/qt-2.0.1 to your environment variable LD_LIBRARY_PATH or make links to the libraries in a standard directory like /usr/local/lib:

    cd /usr/local/lib
    ln -s /opt/qt-1.44/lib/libqt.so.1 .
    ln -s /opt/qt-2.1.0/lib/libqt.so.2 .
    

To develop with Qt 1.4x use:

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

To develop with Qt 2.x use:

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

Setting the PATH ensures that the proper version of moc is being used. Your Makefile should refer to ${QTDIR}/include and ${QTDIR}/lib to include the proper header files and link with the proper libraries.

Using Qt on X11 without a window manager

When using Qt without a window manager on Unix/X11, you will very 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 toplevel window.

Other common problems

Other common problems are covered by the online Technical FAQ.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 79
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

Les bases

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web