how to install qt on ubuntu

3 Easy Ways To Install Any Qt Version On Ubuntu

Qt 6 is a software tool that helps developers create applications with user-friendly interfaces for different devices like computers, smartphones, and tablets. It makes it easier to build applications that are intuitive and visually appealing.

User-friendly, but not necessarily developer-friendly, as you’ll quickly realize. Installing a specific version on Ubuntu can quickly be a headache.

There are different methods available, I tested all of them and will share the top 3 with you in this article, with the commands you need to get started in each case.

Linux doesn’t have to be intimidating. With my e-book, Master Linux Commands, you’ll uncover the secrets of the terminal in a fun, step-by-step journey. From basics to scripts, get ready to level up your Linux skills. Oh, and did I mention the handy cheat sheet you get as a bonus?

Install Qt 6 from the default repository

There is one version of Qt 6 available in the default Ubuntu repository. It’s the easiest way to install it, by using APT in the command line or via a graphical package manager.

This is the easiest way, but you won’t necessarily get the latest version, and it’s not necessarily included with all Ubuntu versions.

At the time of writing, Qt 6.4.2 is available in the repository for Lunar (23.04), while version 6.5.1 can already be downloaded on the website. It’s not a big difference, but it’s still a few months of updates you won’t get.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

If you’re still using an older Ubuntu version, it might even be an older Qt version or not available at all, so this won’t work for everyone. It’s just the easiest method if you don’t care about being a few versions behind.

Here is the command to check which version is available for your system (if any):
apt search qt6-base

Join Our Community!

Connect, learn, and grow with other Raspberry Pi enthusiasts. Support RaspberryTips and enjoy an ad-free reading experience. Get exclusive monthly video tutorials and many other benefits.

Learn more

If you get a similar result, it means it’s available. You can then install it with:
sudo apt install qt6-base-dev

If it’s not available on your Ubuntu version, or if you need a different version of Qt, check out the following methods.

If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy.

Install Qt 6 with Qt Online installer

An installer is available for download on the official Qt website, allowing you to install any Qt version, and also all the other tools and dependencies (like Qt Creator). A Linux version is available and works well on Ubuntu.

An account is required, which might be an issue for some of you, but it’s not complicated to use and allows you to customize exactly what is installed (version, libraries, applications, etc.).

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Here are the steps to use Qt Online Installer on Ubuntu:

  • Download the installation script here:
    https://www.qt.io/download-qt-installer-oss
  • During the download, you can check if you have this package installed, as it was required and missing on my test machine:
    sudo apt install libxcb-xinerama0
  • Once the download is completed, add the execution permissions to the file:
    cd Downloads
    chmod +x qt-unified-linux-x64-<version>-online.run

    Adjust the file name depending on which one you got.
  • Run the script with:
    ./qt-unified-linux-x64-<version>-online.run
  • You’ll have to log in with your Qt Account directly:

    You can create one via the installer if you don’t have one yet (because you need to verify your email address and fill out a form on the website after that before you can use it).
  • Once signed in, accept the license and continue.
  • You’ll get a menu where you can pick what you want to install and customize the installation folder, it’s not complicated, it looks like this:
  • If you keep the defaults (Custom installation), you’ll then have another menu where you can decide exactly what to install (version and packages):
  • Accept the license for the things you are installing, and wait a few minutes.
    The installer will do everything for you in the background, and you’ll soon have everything installed in the folder you have chosen.

If you use Qt Creator, this new version will be automatically available in it:

With other IDEs, you might need to go to the settings and add the installation folder manually.

If you have an account and need a specific version, or specific additional libraries and tools, I think using the installer is probably the best method. It’s not that complicated, it’s customizable and built by the editor.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Install Qt 6 from source on Ubuntu

The source code of Qt is also available on the official website for any version. It can be downloaded and compiled on any computer, as long as all the prerequisites are available.

Installing Qt from source allows you to get the exact version you want, even if it’s really new and not yet available in the repository. It’s a bit more work, but I’ll show you the steps.

Requirements

Many packages are required beforehand, let’s install them first. This long command should cover most of your needs:
sudo apt install build-essential libgl1-mesa-dev cmake libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-cursor-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev

Installation

Once the prerequisites are installed, here are the steps to download and install Qt6 from source:

  • Visit the official website and find the version you want to download.
    You can find the latest official releases directly on their server here.
  • There is a subfolder for each version, and then a folder named “single” where you’ll find the archive, download the “tar.xz” file:

    It’s a big file, so it might take a while on a slow connection.
  • Once the file is downloaded, extract the archive.
    You can use the GUI, or in the command line:
    cd Downloads
    tar xf qt-everywhere-src-6.5.1.tar.xz
    cd qt-everywhere-src-6.5.1
  • Run the configure script with:
    ./configure
    It will tell you if anything is missing on your system, but if you installed the prerequisites listed earlier, it should be fine and you will get a success message like this:
  • You can then start the build process with:
    cmake --build . --parallel
    As often when building from source, it might take a while, just be patient.
  • Once done, complete the installation with:
    cmake --install .

By default, Qt is installed under /usr/local/Qt-<version> (for example: /usr/local/Qt-6.5.1).
You may need to add this folder to your path or IDE configuration to use it after the installation.

To make it work from the command line, you can add these lines to your .profile file:
PATH=/usr/local/Qt-6.5.1/bin:$PATH
export PATH

I hope this article was useful, and if you like Ubuntu/Linux and programming, I have many other articles like that on this website, feel free to check these for example:

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

Additional Resources

Overwhelmed with Linux commands?
My e-book, “Master Linux Commands”, is your essential guide to mastering the terminal. Get practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
Grab your copy now.

VIP Community
If you just want to hang out with me and other Linux fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Python is a great language to get started with programming on any Linux computer.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

Similar Posts