How to update Qt from 5.5.1 to 5.9.5 on Ubuntu 16.04

Solution 1:

A second option is to add Qt using a PPA. The example below installs Qt 5.11.1. There are PPA's for other versions if required.

Add the PPA

sudo add-apt-repository ppa:beineri/opt-qt-5.11.1-xenial
sudo apt update

Install Qt

sudo apt install qt511-meta-full

Configure the System

There are a couple of choices here depending on whether you want to configure the use of the new Qt version system wide or to the current user.

For system wide, create the following file in location /etc/xdg/qtchooser.

For the current user, create the following file in location ~/.config/qtchooser.

Create a text file in the chosen qtchooser folder named default.conf with the following contents:

/opt/qt511/bin
/opt/qt511/lib

The first line in the file is the path to the Qt binaries and the second is the path to the Qt libraries.

Check the Configuration

qmake -v

If the configuration is working correctly you should see something like:

QMake version 3.1
Using Qt version 5.11.1 in /opt/qt511/lib

Solution 2:

You could install Qt using the installers provided by Qt. The open source installer can be downloaded here.

Once downloaded (the following assumes the download location is ~/Downloads):

Install Qt

cd ~/Downloads
chmod +x qt-unified-linux-x64-3.0.5-online.run
./qt-unified-linux-x64-3.0.5-online.run

In the "Installation Folder" screen, enter /opt/Qt.

Qt Install Folder

In the "Select Components" screen, choose the version you would like to install (Qt 5.11.1 used in this example) and tick the "Desktop gcc 64-bit" option.

Qt Select Components

The installer will request your sudo password during installation.

Configure the System

There are a couple of choices here depending on whether you want to configure the use of the new Qt version system wide or to the current user.

For system wide, create the folder qtchooser in location /etc/xdg/ (the location used in this example).

For the current user, create the folder qtchooser in location ~/.config/.

Create a text file in the qtchooser folder created in the previous step named default.conf with the following contents:

/opt/Qt/5.11.1/gcc_64/bin
/opt/Qt/5.11.1/gcc_64/lib

The first line in the file is the path to the Qt binaries and the second is the path to the Qt libraries.

Check the Configuration

qmake -v

If the configuration is working correctly you should see something like:

QMake version 3.1
Using Qt version 5.11.1 in /opt/Qt/5.11.1/gcc_64/lib