Qt 环境搭建

在这里插入图片描述

sudo apt-get upadte
sudo apt-get install qt4-dev-tools
sudo apt-get install qtcreator
sudo apt-get install qt4-doc
sudo apt-get install qt4-qtconfig
sudo apt-get install qt-demos

在这里插入图片描述

编译指令

qmake -project

在这里插入图片描述

qmake

在这里插入图片描述

make

在这里插入图片描述

实现Ubuntu20,04 与Windows之间的复制粘贴
安装open-vm-tools-desktop:sudo apt-get install open-vm-tools-desktop

sudo apt-get install open-vm-tools-desktop /

重启Ubuntu系统:reboot

sudo reboot 
#include<QApplication>
#include<QLabel>
int main(int argc,char** argv)
{
	QApplication app(argc, argv);
	QLabel label("hello world");
	label.show();
	app.exec();
	return 0;
}

The error you’re encountering indicates that the compiler can’t find the QApplication header file, which is part of the Qt framework. This is likely because the necessary Qt development packages are not installed, or the include paths for Qt are not correctly specified.

Here’s how to troubleshoot and resolve this issue:

1. Ensure Qt Development Packages are Installed

On a Debian-based system (like Ubuntu), you can install the necessary Qt development packages with the following command:

sudo apt-get install qt5-default libqt5gui5 libqt5core5a libqt5widgets5

2. Verify Include Paths

Make sure that the include paths specified with -I flags in your command line correctly point to the Qt headers. The paths you used seem to be pointing to the correct directories, but double-check that the headers are indeed located there:

  • /usr/include/x86_64-linux-gnu/qt5
  • /usr/include/x86_64-linux-gnu/qt5/QtGui
  • /usr/include/x86_64-linux-gnu/qt5/QtCore

Specifically, make sure that the QApplication header exists at the expected path, which should be something like:

/usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication

Note that QApplication is part of the QtWidgets module, so you’ll need to include that in your include paths if it isn’t already.

3. Include the Correct Module

Since QApplication is part of the QtWidgets module, you need to ensure that the include path for QtWidgets is specified, and you should explicitly include QtWidgets in your code:

#include <QApplication>

Also, ensure the include path for QtWidgets is set up correctly:

-I/usr/include/x86_64-linux-gnu/qt5/QtWidgets

4. Recompile

After verifying the above steps, try recompiling your code:

g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WIDGETS_LIB -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I. -o day1.o day1/day1.cpp

This should resolve the QApplication not found error.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

料子懒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值