Hi, I'm trying to get route information using qt-mobility 1.1.0 (and qt-4.7.0).
Here I retrieve text instructions for my route:
void MainWindow::routeFinished()
{
QGeoRouteReply *reply = static_cast<QGeoRouteReply*>(sender());
if (!reply)
return;
if (reply->routes().size() < 1)
return;
QGeoMapRouteObject *route = new QGeoMapRouteObject(reply->routes().at(0));
routeColor.setAlpha(127); //semi-transparent
pen.setWidth(7);
pen.setCosmetic(true);
pen.setCapStyle(Qt::RoundCap);
route->setPen(pen);
m_mapWidget->addMapObject(route);
QGeoRouteSegment segment = reply->routes().at(0).firstRouteSegment();
while(segment.isValid())
{
qDebug() << segment.maneuver().instructionText();
segment = segment.nextRouteSegment();
}
}
void MainWindow::routeFinished()
{
QGeoRouteReply *reply = static_cast<QGeoRouteReply*>(sender());
if (!reply)
return;
if (reply->routes().size() < 1)
return;
QGeoMapRouteObject *route = new QGeoMapRouteObject(reply->routes().at(0));
QColor routeColor(Qt::blue);
routeColor.setAlpha(127); //semi-transparent
QPen pen(routeColor);
pen.setWidth(7);
pen.setCosmetic(true);
pen.setCapStyle(Qt::RoundCap);
route->setPen(pen);
m_mapWidget->addMapObject(route);
QGeoRouteSegment segment = reply->routes().at(0).firstRouteSegment();
while(segment.isValid())
{
qDebug() << segment.maneuver().instructionText();
segment = segment.nextRouteSegment();
}
}
To copy to clipboard, switch view to plain text mode
but I get only the first segment's instructions, the others are empty (""), while isValid() goes ok. What am I doing wrong here?
Bookmarks