Qt: QHostAddress: 没有那个文件或目录

Qt: QHostAddress: No such file or directory

我是 Qt 的新手,当我尝试 运行 程序时出现导入错误

fatal error: QHostAddress: No such file or directory

由 main.cpp

中的导入引起
#include <QCoreApplication>
#include <QHostAddress>

似乎缺少QHostAddress.h,而QCoreApplication.h可用

确保你有这样的效果:

QT += network

在您的 .pro 文件中。然后运行再次qmake,重新编译。