There must be some way around this without having to add
The official MSDN documentation says you need to include it, so please do not avoid it.
It is a good practice to always be explicit for your dependencies to avoid hidden dependency issues which can blow up anytime when some included header file does not do the favor for you anymore to include your dependency transparently.
This is probably the reason what is happening in here, too, some dependencies of yours cleaned up the library not to include unnecessary things or it was just redesigned internally.
Alternatively, this function was available in WinBase.h
earlier as per documentation and now that if you switch to a newer Windows, it could also case issues with hidden dependencies.
The lesson to learn is that you wish to be explicit even for the simplest function that is included for sure in other headers you include.
However, you need to learn the difference between
#ifdef Q_OS_WIN32
#include "windows.h"
#endif
and
#ifdef Q_OS_WIN32
#include <windows.h>
#endif
In this case, you should use the latter rather than the former since the latter would be used for system headers like this, whereas the former is normally used for "local" headers in your project.
That being said, you should avoid using WinAPI in your Qt application. This funtcionality is already provided by QThread or the QtTestLib module.
void QThread::msleep(unsigned long msecs) [static]
Forces the current thread to sleep for msecs milliseconds.
and
Sleeps for ms milliseconds, blocking execution of the test. qSleep() will not do any event processing and leave your test unresponsive. Network communication might time out while sleeping. Use qWait() to do non-blocking sleeping.
ms must be greater than 0.
Note: The qSleep() function calls either nanosleep() on unix or Sleep() on windows, so the accuracy of time spent in qSleep() depends on the operating system.
Example:
QTest::qSleep(250);
With Qt 4, you would need to override the protected sleep method of QThread in a subclass and use that. With Qt 5, you could use it directly since it was made public for this reason to avoid the common subclass demanding API.