I am trying to get a QGeoLocation. My version of Qt is 5.7.1, btw, and I am running it on Debian.
I saw this post how to get latitude/longitude from one geo address using Qt c++ on windows?
I copied and pasted the working solution from Scheff's answer, but still got not error and 0 locations. Does this have to do with my setup/environment?
This shorter code has the same effect:
#include <QApplication>
#include <QGeoAddress>
#include <QGeoCodingManager>
#include <QGeoCoordinate>
#include <QGeoLocation>
#include <QGeoServiceProvider>
#include <QtDebug>
int main( int argc, char **argv)
{
QCoreApplication app( argc, argv );
QGeoServiceProvider geoSrv( "osm" );
QGeoCodingManager *geoCoder = geoSrv.geocodingManager();
QGeoAddress addr;
addr.setCountry( "China" );
QGeoCodeReply *geoCode = geoCoder->geocode( addr );
if ( geoCode->error() )
qDebug() << "error";
qDebug() << geoCode->locations().length();
return app.exec();
}