Ubuntu下安装Qt

方法一:
sudo apt-get install qt4-dev-tools
sudo apt-get install qtcreator

 

方法二:

下载http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2010.01.bin

chmod u+x qt-sdk-linux-x86-opensource-2010.01.bin

./qt-sdk-linux-x86-opensource-2010.01.bin

按步骤安装即可,

我这里安装到/usr/qtsdk-2010.01目录下,

然后,gedit ~/bashrc

在最后一行处加上

PATH=$PATH:/usr/qtsdk-2010.01/qt/bin

export PATH

即可。

这里既安装了qtsdk,又安装了qtcreator。

 

1、运行qtcreator可能会显示No valid Qt version set. Set one in Tools/Options之类的信息

“安装完毕之后,新建一个工程,发现如题所示的error,version有问题。在网上查了下,很多人都有碰到,但是都没有写明如何解决,其实,解决方法在Qt Creator的帮助文件里就有提到了:
TermMeaning
Auto-detected QtThe version of Qt installed on your system. This is the Qt version for theqmake command found in your PATH.
Default QtThe version of Qt configured in Tools -> Options -> Qt 4 -> Default Qt Version. This is the Qt version used by your new projects. It defaults to Auto-detected Qt.
Project QtThe version of Qt configured in Build&Run -> Build Settings -> Build Configurations. This is the Qt version that is actually used by a particular project. It defaults to Default Qt.
Shadow BuildShadow building means building a project in a separate directory, the build directory. The build directory is different from the source directory. One of the benefits of shadow building is that it keeps your source directory clean. Shadow building is the best practice if you need many build configurations for a single set of source.

2、也有可能遇上这样的错误信息:make : g++: 命令未找到

出现错误是因为没有安装g++编译器,运行以下命令来安装:
sudo apt-get install g++
应该就好了,如果还没好,再安装这个:
sudo apt-get install pentium-builder

<think>好的,我现在需要在Ubuntu系统上安装Qt开发环境,但我不太清楚具体步骤,应该从哪里开始呢?首先,我记得可以通过包管理器直接安装,比如apt-get。让我查一下有没有相关的命令。哦,对了,用户提供的引用里提到可以使用sudo apt install qt5-default qtcreator,这样应该可以安装基本的Qt5环境和Qt Creator IDE。不过,可能这样安装的版本不是最新的,如果需要特定版本的话可能不够。那如果我要安装较新的版本或者特定版本怎么办?比如用户提到的引用[2]和引用[4]中,提到了使用Qt安装工具或者手动配置路径。可能这时候需要下载官方的在线安装程序,或者通过其他方式安装。另外,还有环境变量的配置问题,比如在.bashrc中添加PATH路径,这样qmake和Qt Creator才能被正确找到。还有,不同的安装方式可能会有不同的依赖问题,比如是否需要安装额外的库或者工具。另外,用户引用[5]提到了一些qt4相关的包,但现在可能更常用的是Qt5或者Qt6,需要注意版本的选择。此外,跨平台开发的话,可能需要配置编译器,比如MinGW或者GCC,确保在Ubuntu上能够正确编译。可能还需要安装一些开发库,比如OpenGL等。总之,安装Qt开发环境有多种方法,需要根据具体需求选择合适的方式,并注意环境配置和依赖项的安装。</think>在Ubuntu系统中安装Qt开发环境主要有三种方法,以下是详细步骤说明: ### 方法一:APT包管理器安装(推荐快速部署) 1. **更新软件源**: ```bash sudo apt update ``` 2. **安装Qt基础库和开发工具**: ```bash sudo apt install qt5-default qtcreator ``` 该命令会安装Qt5的核心库、头文件及Qt Creator IDE[^1][^5]。 3. **验证安装**: ```bash qmake --version # 查看qmake版本 qtcreator & # 启动IDE ``` ### 方法二:官方在线安装(推荐获取最新版本) 1. **下载安装工具**: ```bash wget https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run chmod +x qt-unified-linux-x64-online.run ``` 2. **运行安装程序**: ```bash ./qt-unified-linux-x64-online.run ``` 按向导选择组件(建议勾选MinGW/GCC编译器、Qt Creator及目标版本)[^2][^3]。 3. **配置环境变量**: 在`~/.bashrc`末尾添加: ```bash export PATH="/opt/Qt/Tools/QtCreator/bin:$PATH" export PATH="/opt/Qt/6.7.2/gcc_64/bin:$PATH" ``` 执行`source ~/.bashrc`生效[^4]。 ### 方法三:手动编译安装(适用于定制化需求) 1. **下载源码包**: ```bash wget https://download.qt.io/official_releases/qt/5.12/5.12.12/single/qt-everywhere-src-5.12.12.tar.xz tar -xvf qt-everywhere-src-5.12.12.tar.xz ``` 2. **编译安装**: ```bash cd qt-everywhere-src-5.12.12 ./configure -prefix /opt/Qt5.12.12 make -j$(nproc) sudo make install ``` 3. **配置环境变量**(同方法二)[^4]。 ### 验证开发环境 创建测试项目: ```cpp // main.cpp #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel label("Hello Qt on Ubuntu!"); label.show(); return app.exec(); } ``` 编译命令: ```bash qmake -project && qmake && make ./项目名称 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值