欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > 解决:QTcpSocket: No such file or directory

解决:QTcpSocket: No such file or directory

2025/4/25 13:38:56 来源:https://blog.csdn.net/qq_45855355/article/details/147333192  浏览:    关键词:解决:QTcpSocket: No such file or directory

项目场景:

使用QTcpSocket进行网络编程:
调用connectToHost连接服务器,调用waitForConnected判断是否连接成功,连接信号readyRead槽函数,异步读取数据,调用waitForReadyRead,阻塞读取数据。


问题描述

找不到头文件#include <QTcpSocket>
error: QTcpSocket: No such file or directory In file included from ..\MyChatClient\basewidget\clientsocket.cpp:1: ..\MyChatClient\basewidget\clientsocket.h:5:10: fatal error: QTcpSocket: No such file or directory


原因分析:

需要重新加载网络模块:

QT       += network

解决方案:

在项目的.pro文件中引入网络模块

在这里插入图片描述

总结

在遇到类似于error: QSqlDatabase: No such file or directoryerror: QTcpSocket: No such file or directory的问题,查看项目的.pro文件有没有添加相应的模块。

版权声明:

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

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

热搜词