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

Retreving Contry Location Using GPS in Qt

本文关键字:检索 国家 位置 GPS Qt      更新时间:2023-10-16

我是Qt的新手,我被赋予了这个任务…

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

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

i end up here: http://www.developer.nokia.com/Community/Wiki/File:Qt_for_Maemo_Location_Example.zip

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

..liblocationlocationinfowidget.cpp:1:34: error: hildon/hildon-banner.h: No such file or directory
In file included from ..liblocationlocationinfowidget.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
..liblocationlocationinfowidget.cpp: In constructor 'LocationInfoWidget::LocationInfoWidget(QWidget*)':
..liblocationlocationinfowidget.cpp:33: error: 'control' was not declared in this scope
..liblocationlocationinfowidget.cpp:33: error: 'location_gpsd_control_get_default' was not declared in this scope
..liblocationlocationinfowidget.cpp:35: error: 'location_gpsd_control_start' was not declared in this scope
..liblocationlocationinfowidget.cpp:37: error: 'device' was not declared in this scope
..liblocationlocationinfowidget.cpp:37: error: 'LocationGPSDevice' was not declared in this scope
..liblocationlocationinfowidget.cpp:37: error: expected primary-expression before ')' token
..liblocationlocationinfowidget.cpp:37: error: expected ';' before 'g_object_new'
..liblocationlocationinfowidget.cpp:40: error: 'G_CALLBACK' was not declared in this scope
..liblocationlocationinfowidget.cpp:40: error: 'g_signal_connect' was not declared in this scope
..liblocationlocationinfowidget.cpp: In destructor 'virtual LocationInfoWidget::~LocationInfoWidget()':
..liblocationlocationinfowidget.cpp:50: error: 'device' was not declared in this scope
..liblocationlocationinfowidget.cpp:51: error: 'g_object_unref' was not declared in this scope
..liblocationlocationinfowidget.cpp:53: error: 'control' was not declared in this scope
..liblocationlocationinfowidget.cpp:54: error: 'location_gpsd_control_stop' was not declared in this scope
..liblocationlocationinfowidget.cpp: At global scope:
..liblocationlocationinfowidget.cpp:57: error: variable or field 'updateStatus' declared void
..liblocationlocationinfowidget.cpp:57: error: 'LocationGPSDeviceStatus' was not declared in this scope
mingw32-make[1]: *** [debug/locationinfowidget.o] Error 1
mingw32-make: *** [debug] Error 2

所以我做错了吗?有更简单的方法来做这些事情吗?

第一个错误就说明了一切:" hildon/hildon-banner.h: No such file or directory"

你至少错过了那个文件。可能该文件声明了LocationGPSDeviceFix,这解释了第二个错误"'LocationGPSDeviceFix'未声明"。然后从那里开始走下坡路。在c++中,应该从上到下开始修复错误。

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