Qt

Home page Models Systems Tools IT staff refernces

Installing Qt Using Qt

Qt is a cross platform application framework, including GUI support, thread support and OpenGL support. It has a GUI forms designer called Qt Designer, a full development environment called Qt Creator (for the latest versions of Qt) and an online documentation system called called Qt Assistant. Qt Creator has some nice features - Qt designer is embedded in it and works better than using Qt Designe from within Eclipse, it has support for version control using svn and git, and it has a debugger that works well with C++ (unlike the one in Eclipse) and that shows complex classes, such as the C++ STL classes, in a cleaner way than Eclipse.

This is the Qt web web site.

For a Qt project Qt will create and maintain a project file (.pro file). In Eclipse with the Qt plugin, when new classes or Gui components are added the .pro file will be updated accordingly. The qmake utility will read the .pro file and create the necessary make files for doing builds. The Qt Assistant has tutorial and refernce documentation.

Installing Qt

Linux Install Mac Install Windows Install

Typically we install Qt Creator, which also includes the rest of of Qt - the sdk, Qt Designer and Qt Assistant.

Linux Install

To install Qt Creator, don't use the Ubuntu package for Qt Creator (i.e. don't use apt-get install qtcreator). There is some library mismatch problem that will cause it to be slow and also crash or even hang an entire computer. Download the Qt SDK install package for Linux from the Qt web site, not one of the other Qt install packages, such as the one for Qt Creator. The SDK install package includes all Qt libraries, Qt Creator, Qt Designer and Qt Assistant. The Qt Creator download just includes Qt Creator.

This is a single file. Give this file execute permissions and then run it. For example, if the file name is Qt_SDK_Lin64_offline_v1_1_2_en.run, then do the following:

If you decide not to install the full Qt package with Qt Creator, then use the following commands in a terminal window.

Once installed, whatever Qt components were installed will be available from the Ubuntu Gnome Applications | Programming menu. If Qt Creator was installed then Qt Designer won't have a separate menu entry because it is built-in to Qt Creator. Neither will Qt Assistant (the Qt online documentation tool), but that is probably available in Qt Creator, perhaps in the help menu.

Mac Install

Download the Qt SDK install package for Mac OS/X from the Qt web site, not one of the other Qt install packages, such as the one for Qt Creator. The SDK install package includes all Qt libraries, Qt Creator, Qt Designer and Qt Assistant. The Qt Creator download just includes Qt Creator.

This is a single file. For example, if the file name is Qt_SDK_Mac64_offline_v1_1_2_en.dmg, then do the following:

The Mac Qt installer may not place the Qt programs and utilities in a directory in the usual execution path (such as /usr/bin). Instead it may install them in a sub-directory of the install directory (ex. /Developer/Applications/Qt/Desktop/Qt/474/gcc/bin). Each user on the system will need to add that sub-directory to their path, in file ~/.bash_profile.

Windows Install

Using Qt

Determining Qt Version

The command "qmake -v" will give the version number for both the qmake utility itself and the version number for Qt.

Qt/OpenGL Version Mismatch

There can be an incompatilbiltiy problem between the version of OpenGL installed on a system and the version of Qt used on that system. This can happen if the driver for the video card on a system is upgraded and that new driver uses a version of OpenGL that is newer than the installed version of Qt is aware of. It can also happen if a brand new system is set up with a current generation video card, which will use the latest OpenGL version, but an older version of Qt is installed.

The symptoms will be that a warning message, "Unrecognized OpenGL version", is displayed on the console when a gui version of one of our models that uses Qt is run. The model may also get a segmentation fault. That seems to happen most often when using a gui version of a model to generate png snapshots from a saved state.

The fix is to uninstall Qt and install the latest version. Despite this the include files and libraries for the older version may still exist on the system. This seems to be true of Ubuntu Linux since it seems to use Qt for the gnome window manager. In any case, you need to make sure that a command to run qmake invokes the qmake for the latest version of Qt. On Ubuntu you can move /usr/bin/qmake to /usr/bin/qmake.M.m.b (where M, m and b are the components of the older Qt version number, ex. 4.6.2) and then make /usr/bin/qmake a link to the qmake for the latest version of Qt. To make sure this worked use "qmake -v" . Then run qmake on any of the models already checked out from the archive on the system that was updated. This wll re-create the make files for the gui versions of those models to refer to the include files and libraries for the newer version of Qt instead of the older version. Without this last step any builds using the un-updated make files will use the older version of Qt and therefore still have the OpenGL version mis-match problem.

Qt, .pro file, qmake and Eclipse Qt plugin

For a Qt project, such as code for one of our models, Qt will create and maintain a project file (.pro file), for example for the lung model it is grviz.pro. In Eclipse with the Qt plugin, when new classes or Gui components are added the .pro file will be loaded in an editor window and updated with the new classes or gui components. You must save it and then run qmake in a terminal window to create updated make files (there may be a way to run qmake from with in Eclipse).

Eclipse Qt plugin issue - wants to add a file to the .pro file

If using Eclipse or Qt Creator, when a checkout from svn is complete Qt may ask if you want to add a file to the ".pro" file for the project. This typically is refering to a file which is not used with Qt, such as a file containing a main function for a non-gui version of a model. Click cancel, since the ".pro" file is only for files used in a gui version of a model (a version that uses Qt).

Qt, qmake and SVN

After a svn check out (svn co) or svn update (svn up), in a terminal window run the following commands.

Qt app executables on a mac

On a Mac, the .pro file will generate make files that store the executable for a build in a Mac application bundle. This is very inconvenient when running the executable from a command line, which is what we typically do when running our models, since it is buried several levels down a directory tree. To avoid this, place the following line in the macx section of the .pro file (the macx section begins with "macx:"), if not already there:

CONFIG -= app_bundle

Set up location of release and debug - the source main directory

Qt Creator and SVN

The Qt Creator SVN integration does not include a capability to checkout svn projects. That must be done using the command line client.

SVN does not appear in the Tools menu until you open a project checked out from an SVN repository.

May get an error about can't save to a configuration file: may have to manually change ownership of ~/.config directory from root to your user name: sudo chown -R user-name:user-name ~/.config