Through a reply I received from a user here from Stack Overflow in English, this can be found here, I was able to elaborate a function that can perfectly find the coordinates through the address, follows:
QGeoCoordinate MainWindow::getGeoCoordinates() {
QEventLoop loop;
QGeoCoordinate qGeoCoord;
QStringList qGeoSrvList = QGeoServiceProvider::availableServiceProviders();
for (QString entry : qGeoSrvList) {
QGeoServiceProvider qGeoService(entry);
QGeoCodingManager *pQGeoCoder = qGeoService.geocodingManager();
if ( ( qGeoService.error() == 0 ) && ( qGeoService.errorString().compare("") == 0 ) ) {
QLocale qLocaleC(QLocale::C, QLocale::AnyCountry);
pQGeoCoder->setLocale(qLocaleC);
QGeoAddress qGeoAddr;
qGeoAddr.setCountry( "país" );
qGeoAddr.setPostalCode( "cep" );
qGeoAddr.setCity( "cidade" );
qGeoAddr.setStreet( "rua, número" );
qGeoAddr.setState( "estado" );
QGeoCodeReply *pQGeoCode = pQGeoCoder->geocode(qGeoAddr);
connect( pQGeoCode, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
if ( pQGeoCode->error() != QGeoCodeReply::NoError ) {
qDebug() << pQGeoCode->error() << " | " << pQGeoCode->errorString();
break;
} else {
QList<QGeoLocation> qGeoLocs = pQGeoCode->locations();
for (QGeoLocation &qGeoLoc : qGeoLocs) {
qGeoLoc.setAddress(qGeoAddr);
qGeoCoord = qGeoLoc.coordinate();
}
}
}
}
return qGeoCoord;
}
OBS: Remembering that no . pro should be added QT += Positioning Location