Through a response I received from a user here from Stack Overflow in English, this can be found here , I could elaborate a function that perfectly can find the coordinates through the address,
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;
}
NOTE: Remembering that .pro should be added QT + = positioning location