Your problem is the following line:
QTEST_MAIN(WatermarkingTests)
From the documentation:
QTEST_MAIN ( TestClass )
Implements a main() function that instantiates an application object and the TestClass, and executes all tests in the order they were defined. Use this macro to build stand-alone executables.
If QT_GUI_LIB is defined, the application object will be a QApplication, otherwise it will be a QCoreApplication. If qmake is used and the configuration includes QT += gui, then QT_GUI_LIB will be defined automatically.
This means, you will get a QApplication rather than QCoreApplication since the QT
variable contains core and gui by default. You would need to use the following statement to get around it:
QT = core testlib
Note that with Qt 5, you can just the following macro instead:
QTEST_GUILESS_MAIN( TestClass)
Implements a main() function that instantiates a QCoreApplication object and the TestClass, and executes all tests in the order they were defined. Use this macro to build stand-alone executables.
Behaves like QTEST_MAIN(), but instantiates a QCoreApplication instead of the QApplication object. Use this macro if your test case doesn't need functionality offered by QApplication, but the event loop is still necessary.
This function was introduced in Qt 5.0.