I'm writing test automation in QT. I'am using QTest::qWaitFor
to wait until the event loop switches to another tab in UI.
QTest::qWaitFor([tabs, ¤tIdx]() {
currentIdx = tabs->currentIndex();
return currentIdx == 1;
}, 5000);
Each time I'am using such construction following warning appears:
ignoring return value of function declared with 'warn_unused_result' attribute
I spent hours dealing with it but no result. I think the problem is the way functions consume returned values from lambda expressions. Is there any workaround?
Issue is not with lambda, but your usage:
You should use/check return value of qWaitFor
(to know if timeout happens):
if (QTest::qWaitFor([tabs, ¤tIdx]() {
currentIdx = tabs->currentIndex();
return currentIdx == 1;
}, 5000)) {
// OK.
// ...
} else {
// timeout.
// ...
}