Hello,
Is there a way to call LocationToElevation synchronically?
Something like the "await" in C# that will bypass the need to always wait for the slot...
It makes calculations so complicated when there is, for example, a loop in which each iteration needs the elevation.
Thanks
Solved! Go to Solution.
Hi Anat, I hope you are well. Unfortunately, we do not currently have a synchronous version of this call. One approach that might work for you is to create a QEventLoop which you can run to wait until the operation completes.
I've included some code below that shows how that could work - any questions, let me know:
auto startTaskId = surface->locationToElevation(loc).taskId();
QEventLoop loop;
loop.connect(surface, &Surface::locationToElevationCompleted, this, [this, &loop, startTaskId](QUuid taskId, double elevation)
{
if (taskId != startTaskId)
return;
qDebug() << elevation;
loop.quit();
});
loop.connect(surface, &Surface::errorOccurred, &loop, &QEventLoop::quit);
loop.exec();
Hi Anat, I hope you are well. Unfortunately, we do not currently have a synchronous version of this call. One approach that might work for you is to create a QEventLoop which you can run to wait until the operation completes.
I've included some code below that shows how that could work - any questions, let me know:
auto startTaskId = surface->locationToElevation(loc).taskId();
QEventLoop loop;
loop.connect(surface, &Surface::locationToElevationCompleted, this, [this, &loop, startTaskId](QUuid taskId, double elevation)
{
if (taskId != startTaskId)
return;
qDebug() << elevation;
loop.quit();
});
loop.connect(surface, &Surface::errorOccurred, &loop, &QEventLoop::quit);
loop.exec();