在Qt中使用GPS检索国家位置

时间:2011-08-05 08:35:41

标签: c++ qt gps

我是Qt的新手,我已经接受了这项任务......

使用GPS检测国家/地区 - 并在文本框中显示。

好吧,因为我是新手,我不知道怎么做这样的事情。我开始通过互联网搜索

我最终来到这里:http://www.developer.nokia.com/Community/Wiki/File:Qt_for_Maemo_Location_Example.zip

所以我下载了代码并运行它,出现了大量的错误

..\liblocation\locationinfowidget.cpp:1:34: error: hildon/hildon-banner.h: No such file or directory
In file included from ..\liblocation\locationinfowidget.cpp:5:
..\liblocation\/locationinfowidget.h:18: error: 'LocationGPSDeviceFix' has not been declared
..\liblocation\/locationinfowidget.h:20: error: 'LocationGPSDeviceStatus' has not been declared
..\liblocation\/locationinfowidget.h:23: error: 'LocationGPSDevice' has not been declared
..\liblocation\/locationinfowidget.h:23: error: 'gpointer' has not been declared
..\liblocation\/locationinfowidget.h:24: error: 'LocationGPSDevice' has not been declared
..\liblocation\/locationinfowidget.h:24: error: 'gpointer' has not been declared
..\liblocation\/locationinfowidget.h:25: error: 'LocationGPSDevice' has not been declared
..\liblocation\/locationinfowidget.h:25: error: 'gpointer' has not been declared
..\liblocation\/locationinfowidget.h:33: error: ISO C++ forbids declaration of 'LocationGPSDevice' with no type
..\liblocation\/locationinfowidget.h:33: error: expected ';' before '*' token
..\liblocation\/locationinfowidget.h:34: error: ISO C++ forbids declaration of 'LocationGPSDControl' with no type
..\liblocation\/locationinfowidget.h:34: error: expected ';' before '*' token
..\liblocation\locationinfowidget.cpp: In constructor 'LocationInfoWidget::LocationInfoWidget(QWidget*)':
..\liblocation\locationinfowidget.cpp:33: error: 'control' was not declared in this scope
..\liblocation\locationinfowidget.cpp:33: error: 'location_gpsd_control_get_default' was not declared in this scope
..\liblocation\locationinfowidget.cpp:35: error: 'location_gpsd_control_start' was not declared in this scope
..\liblocation\locationinfowidget.cpp:37: error: 'device' was not declared in this scope
..\liblocation\locationinfowidget.cpp:37: error: 'LocationGPSDevice' was not declared in this scope
..\liblocation\locationinfowidget.cpp:37: error: expected primary-expression before ')' token
..\liblocation\locationinfowidget.cpp:37: error: expected ';' before 'g_object_new'
..\liblocation\locationinfowidget.cpp:40: error: 'G_CALLBACK' was not declared in this scope
..\liblocation\locationinfowidget.cpp:40: error: 'g_signal_connect' was not declared in this scope
..\liblocation\locationinfowidget.cpp: In destructor 'virtual LocationInfoWidget::~LocationInfoWidget()':
..\liblocation\locationinfowidget.cpp:50: error: 'device' was not declared in this scope
..\liblocation\locationinfowidget.cpp:51: error: 'g_object_unref' was not declared in this scope
..\liblocation\locationinfowidget.cpp:53: error: 'control' was not declared in this scope
..\liblocation\locationinfowidget.cpp:54: error: 'location_gpsd_control_stop' was not declared in this scope
..\liblocation\locationinfowidget.cpp: At global scope:
..\liblocation\locationinfowidget.cpp:57: error: variable or field 'updateStatus' declared void
..\liblocation\locationinfowidget.cpp:57: error: 'LocationGPSDeviceStatus' was not declared in this scope
mingw32-make[1]: *** [debug/locationinfowidget.o] Error 1
mingw32-make: *** [debug] Error 2

所以我做错了吗?有没有更简单的方法来做这些事情?请具体,我将不胜感激

1 个答案:

答案 0 :(得分:0)

嗯,第一个错误确实说明了一切:“hildon/hildon-banner.h:没有这样的文件或目录”。

你至少缺少那个文件。可能该文件声明为LocationGPSDeviceFix,这解释了第二个错误“'LocationGPSDeviceFix'尚未声明”。从那里开始走下坡路。在C ++中,您应该从上到下开始修复错误。

顺便说一句,GPS只是告诉你经度和latittude。您需要地图才能将其转换为国家/地区。电话网络ID可能更容易;前三位数字是移动国家代码(MCC)