用户名: 密码: 忘记密码? 注册
收藏此问题 发表新评论

Qt 获取IP地址问题

我要获取主机的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
我的头文件已经加了问什么还有这个错误啊?请高手指点下,分不多了,不好意思
昵称: marcomo1986  时间: 2011-06-08 14:45:50
可能是要在.pro文件中添加一些东西,比如qt要使用sqlite数据库就必须在.pro文件加上 QT +=sql
昵称: haixuelang  时间: 2011-06-08 17:09:28
发表评论
昵称:
内容:
验证: