diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 9d79439e049eefb56ef60997933d67910dfd6ff3..14ee0865eb4a1a507b0302f9cbe566eecad3fed6 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -238,7 +238,7 @@ namespace QTest
     inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, char*>::Type toString(T e)
     {
         QMetaEnum me = QMetaEnum::fromType<T>();
-        return qstrdup(me.key(int(e))); // int cast is necessary to support enum classes
+        return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes
     }
 
     template <typename T> // Fallback
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 6446fec51097270f0bc76f97f0a6cd914617ed6a..09a90508d33bda77a83f89f023a161f569270395 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -156,8 +156,9 @@ void tst_Cmptest::compare_unregistered_enums()
 
 void tst_Cmptest::compare_registered_enums()
 {
-    QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor);
-    QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor);
+    // use an enum that doesn't start at 0
+    QCOMPARE(Qt::Monday, Qt::Monday);
+    QCOMPARE(Qt::Monday, Qt::Sunday);
 }
 
 static bool boolfunc() { return true; }
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 36929cec6bca60d2bd208f4959a714687653c514..8f02e2e1ad11500d494853c9fdaf853c2d5f0b24 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -16,8 +16,8 @@
 <TestFunction name="compare_registered_enums">
 <Incident type="fail" file="tst_cmptest.cpp" line="160">
     <Description><![CDATA[Compared values are not the same
-   Actual   (Qt::ArrowCursor): ArrowCursor
-   Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+   Actual   (Qt::Monday): Monday
+   Expected (Qt::Sunday): Sunday]]></Description>
 </Incident>
     <Duration msecs="0"/>
 </TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index 70c54704f94b10ff4d91e5cc92201d8928c6631b..920565850900f9bb1af40f8791518ac3e6dbaea9 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -4,8 +4,8 @@ PASS   : tst_Cmptest::initTestCase()
 FAIL!  : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
    Loc: [tst_cmptest.cpp(154)]
 FAIL!  : tst_Cmptest::compare_registered_enums() Compared values are not the same
-   Actual   (Qt::ArrowCursor): ArrowCursor
-   Expected (Qt::BusyCursor) : BusyCursor
+   Actual   (Qt::Monday): Monday
+   Expected (Qt::Sunday): Sunday
    Loc: [tst_cmptest.cpp(160)]
 PASS   : tst_Cmptest::compare_boolfuncs()
 PASS   : tst_Cmptest::compare_pointerfuncs()
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index 9437e8e4b7c3ade760bb55e12113aa93ce981b64..55a97062276dea740b87900348a31f18148e5d40 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -18,8 +18,8 @@
 <TestFunction name="compare_registered_enums">
 <Incident type="fail" file="tst_cmptest.cpp" line="160">
     <Description><![CDATA[Compared values are not the same
-   Actual   (Qt::ArrowCursor): ArrowCursor
-   Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+   Actual   (Qt::Monday): Monday
+   Expected (Qt::Sunday): Sunday]]></Description>
 </Incident>
     <Duration msecs="0"/>
 </TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index fa970d41726cfb50b8b5e770fbd080fc16f4b5e0..c26f723cfc0049ae0b899d32b7586161226dcb27 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -11,8 +11,8 @@
   </testcase>
   <testcase result="fail" name="compare_registered_enums">
     <failure message="Compared values are not the same
-   Actual   (Qt::ArrowCursor): ArrowCursor
-   Expected (Qt::BusyCursor) : BusyCursor" result="fail"/>
+   Actual   (Qt::Monday): Monday
+   Expected (Qt::Sunday): Sunday" result="fail"/>
   </testcase>
   <testcase result="pass" name="compare_boolfuncs"/>
   <testcase result="pass" name="compare_pointerfuncs"/>