创建QGeoAddress以获取LNK2019
creating QGeoAddress getting a LNK2019
我想用C++对地址进行地理编码,并想使用QtLocation和Qt定位功能。我认为第一步是创建一个QGeoAddress。但这并不奏效。我收到LNK2019故障。如果你能帮我就太好了!
#include <QCoreApplication>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <regex>
#include <string>
#include <streambuf>
#include <QtPositioning/QGeoAddress.h>
#include <QtPositioning/QGeoLocation>
#include <QtLocation/QGeoCodingManager>
#include <QtLocation/QGeoServiceProvider>
#include <QString>
#include <QtLocation/QGeoCodeReply>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QGeoAddress searchAddress;
}
错误消息是(很抱歉是德语):
main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: __cdecl QGeoAddress::QGeoAddress(void)" (__imp_??0QGeoAddress@@QEAA@XZ)" in Funktion "main".
main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: __cdecl QGeoAddress::~QGeoAddress(void)" (__imp_??1QGeoAddress@@QEAA@XZ)" in Funktion "main".
debugRegex_GeoModA_Qt.exe : fatal error LNK1120: 2 nicht aufgelöste Externe
QNetworkAccessManager* manager = new QNetworkAccessManager;
connect(manager, SIGNAL(finished(QNetworkReply*)), SLOT(fReply(QNetworkReply*)));
QString url = QString("http://maps.google.com/maps/api/geocode/json?address=%1&sensor=false&language=en").arg(your_address);
manager->get(QNetworkRequest(QUrl(url)));
void fReply(QNetworkReply *reply)
{
QString json = reply->readAll();
QString strUrl = reply->url().toString();
QJson::Parser parser;
bool ok;
// json is a QString containing the data to convert
//QVariant result = parser.parse (json.toLatin1(), &ok);
QVariant result = parser.parse (json.toLatin1(), &ok);
if(!ok)
{
qDebug()<< (QString("HATA : Cannot convert to QJson object: %1").arg(json));
return;
}
QString code = result.toMap()["status"].toString();
qDebug() << "Code" << code;
if(code != "OK")
{
qDebug() << (QString("HATA : Code of request is: %1").arg(code));
return;
}
QVariantList results = result.toMap()["results"].toList();
if(results.count() == 0)
{
qDebug() << (QString("HATA : Cannot find any locations"));
return;
}
double east = results[0].toMap()["geometry"].toMap()["location"].toMap()["lng"].toDouble();
double north = results[0].toMap()["geometry"].toMap()["location"].toMap()["lat"].toDouble();
}
这段代码需要额外的QJson对象库。
您可以从这里下载源代码并进行编译和使用。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 如何在openssl-ecc中获取十六进制格式的私钥
- 使用Unreal C++获取VR耳机的世界位置/方向
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 从C字符串中获取奇怪的字符串长度
- 为什么我的for循环不能正确获取argv
- 从python中调用C++函数并获取返回值
- 如何获取一个数字的前3位
- 获取字符串的长度并将其分配给数组
- 创建QGeoAddress以获取LNK2019
- 尝试在Qt中获取自定义窗口框架时LNK2019问题
- 获取"error LNK2019: unresolved external symbol ... "
- 简单程序获取LNK2019:未解析的外部符号Visual Studio 2013
- 正在获取lnk2019 VC++
- Visual Studio使用链接器LNK2019获取两个未解析的外部
- 获取"error LNK2019: unresolved external symbol"