欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 手游 > Qt 环境搭建

Qt 环境搭建

2025/4/26 12:44:32 来源:https://blog.csdn.net/qq_17018135/article/details/141506080  浏览:    关键词: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.

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词