diff --git a/src/testlib/qpropertytesthelper_p.h b/src/testlib/qpropertytesthelper_p.h index b4fc0fb7694..06d503f8756 100644 --- a/src/testlib/qpropertytesthelper_p.h +++ b/src/testlib/qpropertytesthelper_p.h @@ -108,7 +108,12 @@ void testReadWritePropertyBasics( std::function represent = [](const PropertyType &val) { return QTest::toString(val); }, std::function(void)> helperConstructor = - []() { return std::make_unique(); }) + []() { + if constexpr (std::is_default_constructible_v) + return std::make_unique(); + else + return std::unique_ptr(); + }) { // get the property const QMetaObject *metaObject = instance.metaObject(); @@ -281,7 +286,12 @@ void testWriteOncePropertyBasics( std::function represent = [](const PropertyType &val) { return QTest::toString(val); }, std::function(void)> helperConstructor = - []() { return std::make_unique(); }) + []() { + if constexpr (std::is_default_constructible_v) + return std::make_unique(); + else + return std::unique_ptr(); + }) { Q_UNUSED(helperConstructor);