[Development] Thank you for qScopeGuard

Henry Skoglund henry at tungware.se
Fri Feb 21 14:21:28 CET 2020


Hi, just want to thank whoever worked to implement qScopeGuard (in 
5.12), it was a perfect gift from heaven today :-)

I'm writing a LOB app with heavy database munging, and want to show the 
user an hourglass cursor while munging/waiting for MS SQLServer.
However my functions have lots of exits due to bad weather etc. and I 
dreaded pasting a restore-mouse-cursor call everywhere. Googled a bit 
and now I use this 2-line magic at the top of my functions:
...
     qApp->setOverrideCursor(Qt::WaitCursor);
     auto restoreCursor = qScopeGuard([] { 
qApp->restoreOverrideCursor(); });
...

Before I discovered Qt I spent 20 years in MFC purgatory, but now I've 
seen the light!



More information about the Development mailing list