There are two primary methods to install Qt 6 and Qt Creator on Ubuntu 24.04: using the official Qt online installer or using the Ubuntu package manager (apt).
使用官方的 在线安装包可能会 在下载列表的额时候 卡主,网络不卡的 推荐
- Using the Official Qt Online Installer (Recommended for latest versions): This method provides the latest versions of Qt 6 and Qt Creator directly from Qt. Download the installer: Visit the official Qt website and download the online installer for Linux. The file will typically be named qt-unified-linux-x64-version-online.run. Make the installer executable: Open a terminal and navigate to the directory where you downloaded the installer (e.g., ~/Downloads). Then, make it executable:
chmod +x qt-unified-linux-x64-*-online.run
Run the installer: Execute the installer:
./qt-unified-linux-x64-*-online.run
Follow the on-screen instructions: The installer will guide you through the process, allowing you to select the desired Qt versions, components (including Qt Creator), and installation location. You may need a Qt account to proceed.
这个是实测可以正常运行的方法, 感谢 google ai 喷出来这个教程
- Using the Ubuntu Package Manager (apt): This method installs the versions of Qt 6 and Qt Creator packaged for Ubuntu 24.04, which may not always be the absolute latest. Update package lists.
sudo apt update
Install Qt 6 development packages.
sudo apt install qt6-base-dev qt6-base-private-dev qt6-declarative-dev qt6-tools-dev
This command installs essential Qt 6 development libraries and tools. You can install other specific Qt 6 modules as needed (e.g., qt6-quick3d-dev, libqt6svg6-dev). Install Qt Creator.
sudo apt install qtcreator
After Installation (for both methods): Launch Qt Creator: You can typically find Qt Creator in your applications menu or launch it from the terminal by typing qtcreator. Configure Qt Versions (if using the installer or multiple Qt versions): In Qt Creator, go to Tools > Options > Kits > Qt Versions and ensure the installed Qt 6 version is detected and configured. You might need to add it manually if it's not automatically detected. Note: If you encounter issues with dependencies or missing libraries, especially when building from source or using specific Qt modules, you may need to install additional development packages (e.g., build-essential, libgl1-mesa-dev, libvulkan-dev).
sudo apt install qtcreator
补充: 安装了上面这一坨,东西该有的都有了,但是在创建 qt 项目时,选择 qmake ,创建好项目后,还是会遇到这样一个问题,
this file is not part of any project,the code model might have issues
原因是,上面的安装 同时安装了 g++ 和 clang++ 两种 c++ 编译器, qt creator 默认配置的 c++ 编译器也是 clang++ , 改为 g++ 就好了。