Tests: Add missing guards on Qt4 and Qt5 tests

Add missing `CMake_TEST_Qt{4,5}` conditions on Qt4 an Qt5 tests.
Configuring CMake with `-DCMake_TEST_Qt5=OFF` should prevent any
attempt to search for Qt5.

Fixes: #23239
33 jobs for !6998 with test-qt-disable in 31 minutes and 50 seconds (queued for 4 seconds)
latest merge request