Installing the Qt SDK

Update: Bits of this have been obsoleted with the 4.7.3 release. I'll try to post an update soon. [09 May 2011]

Because I live fast and loose and on the bleeding edge, I decided to install the Qt SDK using the Nokia download rather than from my distros' package manager. Actually, the real reason is that I was seeing a weird message in the debugger in Qt Creator on Ubuntu 10.10 and hoped the a newer SDK would fix that. But alas it did not--on neither my Ubuntu nor my Debian Squeeze development system. But I will continue to use the downloaded SDK because it will let me update to the latest versions.*

What follows is a brief guide to help you integrate the downloaded SDK into your system should you opt to do so.

The most important difference between installing the downloaded SDK versus installing from the repositories is that the downloaded install will only install for a single user.** The installation itself is pretty straightforward:
  1. Download the installer.
  2. Make the installer executable: In a term open to the directory where you downloaded the installer, enter the command
    $ chmod u+x {the-name-of-the-installer}
    In my case {the-name-of-the-installer} was qt-sdk-linux-x86-opensource-2010.05.1.bin
  3. In the same term, issue
    $ ./{the-name-of-the-installer}
    and follow the resulting directions. The installer will let you pick the directory where the SDK will go. Don't feel obliged to use the default. Because I didn't want another visible directory in my home directory, I installed into ~/.opt/qtsdk.
The above will install all the SDK bits in the specified directory and create two *.desktop entries for the Qt Creator IDE: one on your desktop (drag it to the trash) and the other in your ~/.local/share/applications directory--so that you get a menu entry for it.

Adding some missing bits
The above process gives you a working SDK that's well suited to using the Qt Creator IDE. However, for more general work there are a few things missing:
  1. qmake and other executables will not be available as system commands
  2. There is no menu entry for the Qt Designer GUI layout tool.
The first is required if you plan to do Qt development with another IDE (Netbeans, Eclipse, Monkey Studio, etc.). The second is nice to have in any case. Both are fairly easy to fix.

Making the SDK commands available
To do this we are going to edit your .profile file. Before making changes to your .profile, make a backup of it so you can get back to it easily if you break something! If you have also installed the SDK from the repositories, what follows will cause the repository commands to be overridden by the commands in the local SDK. If you don't want this, then don't do this.

Open ~/.profile in a text editor. Toward the bottom, add the following:
# set PATH so it includes local Qt SDK tools
if [ -d "$QTSDK_LOCATION/qt/bin" ] ; then
if [ -d "$QTSDK_LOCATION/bin" ] ; then
making sure to change QTSDK_LOCATION as needed for your installation. When you logout and log back in, the executables in the two bin directories should be available as commands. Test this by issuing
$ qmake -v
in a term. The output should make sense.

Adding an entry for Qt Designer to the menu
Assuming you have done the stuff in Making the SDK commands available, you can just add the following file as Nokia-QtDesigner.desktop to ~/.local/share/applications
[Desktop Entry]
Exec=designer %F
Name=Qt Designer
GenericName=GUI designer for Qt applications

If you have not done the Making the SDK commands available stuff, then change the Exec= line to point directly at the designer executable (which should be in {qtsdk}/qt/bin)

Now I'm going to move on to testing alternatives to Qt Creator. Qt Creator has a very nice feature set, but the UI is a bit quirky. I'll let you know if I find anything I like better.

* A possible consequence of this is that installing extra bits and baubles will no longer be easy. For example, it seems the Qt4 Designer plugin for QScintilla 2 (libqscintilla2-designer in Debian-land) doesn't ship with Nokia's SDK, and I don't know if Qt Designer will pick up libs installed in standard system library locations.
** I'm quite certain that you can install the downloaded SDK for all users, for example by installing as root into /opt. However, doing so may generate *.desktop files on root's desktop and in root's .local/share/applications dir, and I am not sure if that will mess anything up. If you try this, please let me know how it worked for you.


gouchout said…
Is that the offline installer or the web installer? (the offline one is rather large (787 MB) & I wondered if the web one was less huge - or is there no difference?)
I was also thinking of using something like alien, so I could actually install a package, or perhaps "checkinstall", that I've just noticed.
Mithat said…
@gouchout: I'm pretty sure at the time I did my installs there was only one installer and that it was an offline installer. If I were to re-install today, I would probably go with the offline installer because (1) I won't need a good chunk of what's in the 787 MB d/l and (2) Whatever I *do* install from the 787 MB will get updated soon enough anyway.

I used to use checkinstall whenever I could, though never with the Qt SDK. checkinstall is fabulous when it works well. However, I found increasingly that it wouldn't quite work with the stuff I was trying to install, so I now prefer to do the classic 'make' and 'make install', documenting what went where in case the 'make uninstall' is messy. Alternately, when s/w allows (e.g., Qt SDK, Eclipse, NetBeans, EasyMercurial) I install as user into a subdirectory in ~/.opt.

I don't think I've ever worked with alien. Please share your experiences if you do.

Popular posts from this blog

Ubuntu font rendering in Debian Squeeze

Fixing Qt5 themes in Xfce

Fixing Chromium remote extension loading in Debian sid