Qt 获取IP地址问题
时间:2011-06-08
来源:互联网
我要获取主机的IP地址,我上网搜了搜写了下面几句话
#include <qhostinfo.h>
#include <qhostaddress.h>
QString str=QHostInfo::localHostName();
QHostInfo info=QHostInfo::fromName(str);
QHostAddress address=info.addresses().first();
str=address.toString();
结果出现了下面的错误:
Makefile:120: warning: overriding commands for target `moc_record.cpp'
Makefile:117: warning: ignoring old commands for target `moc_record.cpp'
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/arm/qt-2.3.x/qt-2.3.2/include -o main.o main.cpp
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/arm/qt-2.3.x/qt-2.3.2/include -o record.o record.cpp
record.cpp:19:23: qhostinfo.h: 没有那个文件或目录
record.cpp: In constructor `Form1::Form1(QWidget*, const char*, bool, unsigned
int)':
record.cpp:39: error: `QHostInfo' undeclared (first use this function)
record.cpp:39: error: (Each undeclared identifier is reported only once for
each function it appears in.)
record.cpp:39: error: syntax error before `::' token
record.cpp:42: error: `info' undeclared (first use this function)
make: *** [record.o] Error 1
我的头文件已经加了问什么还有这个错误啊?请高手指点下,分不多了,不好意思
#include <qhostinfo.h>
#include <qhostaddress.h>
QString str=QHostInfo::localHostName();
QHostInfo info=QHostInfo::fromName(str);
QHostAddress address=info.addresses().first();
str=address.toString();
结果出现了下面的错误:
Makefile:120: warning: overriding commands for target `moc_record.cpp'
Makefile:117: warning: ignoring old commands for target `moc_record.cpp'
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/arm/qt-2.3.x/qt-2.3.2/include -o main.o main.cpp
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/arm/qt-2.3.x/qt-2.3.2/include -o record.o record.cpp
record.cpp:19:23: qhostinfo.h: 没有那个文件或目录
record.cpp: In constructor `Form1::Form1(QWidget*, const char*, bool, unsigned
int)':
record.cpp:39: error: `QHostInfo' undeclared (first use this function)
record.cpp:39: error: (Each undeclared identifier is reported only once for
each function it appears in.)
record.cpp:39: error: syntax error before `::' token
record.cpp:42: error: `info' undeclared (first use this function)
make: *** [record.o] Error 1
我的头文件已经加了问什么还有这个错误啊?请高手指点下,分不多了,不好意思
作者: marcomo1986 发布时间: 2011-06-08
可能是要在.pro文件中添加一些东西,比如qt要使用sqlite数据库就必须在.pro文件加上 QT +=sql
作者: haixuelang 发布时间: 2011-06-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28