I have Qt code that looks like following:
class test_gadget { Q_GADGET Q_PROPERTY(QString test MEMBER test)public: QString test;};class test_gadget2 { Q_GADGET Q_PROPERTY(QVector<test_gadget> testo MEMBER testo)public: QVector<test_gadget> testo;};class test_object : public QObject { Q_OBJECT Q_PROPERTY(QVector<test_gadget2> gadget MEMBER gadget)public: test_object(const test_gadget2& g);private: QVector<test_gadget2> gadget;};
However, when I tried to compile, it gives these errors
In file included from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\mocs_compilation.cpp:2:C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp: In static member function 'static void test_gadget2::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:211:27: error: no match for 'operator!=' (operand types are 'QVector<test_gadget>' {aka 'QList<test_gadget>'} and 'QList<test_gadget>') 211 | if (_t->testo != *reinterpret_cast< QList<test_gadget>*>(_v)) { | ~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | QList<[...]> | QList<[...]>In file included from C:/Qt/6.6.0/mingw_64/include/QtCore/qurl.h:11, from C:/Qt/6.6.0/mingw_64/include/QtQml/qqmlengine.h:7, from C:/Qt/6.6.0/mingw_64/include/QtQml/QQmlEngine:1, from C:/Users/USER/source/repos/testqt2/test.hpp:2, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:9, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\mocs_compilation.cpp:2:C:/Qt/6.6.0/mingw_64/include/QtCore/qlist.h:341:56: note: candidate: 'template<class U> QTypeTraits::compare_eq_result_container<QList<T>, U> QList<T>::operator!=(const QList<T>&) const [with U = U; T = test_gadget]' 341 | QTypeTraits::compare_eq_result_container<QList, U> operator!=(const QList &other) const | ^~~~~~~~C:/Qt/6.6.0/mingw_64/include/QtCore/qlist.h:341:56: note: template argument deduction/substitution failed:In file included from C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/move.h:57, from C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/stl_pair.h:59, from C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/utility:70, from C:/Qt/6.6.0/mingw_64/include/QtCore/qcompilerdetection.h:861, from C:/Qt/6.6.0/mingw_64/include/QtCore/qgenericatomic.h:8, from C:/Qt/6.6.0/mingw_64/include/QtCore/qatomic_cxx11.h:8, from C:/Qt/6.6.0/mingw_64/include/QtCore/qbasicatomic.h:8, from C:/Qt/6.6.0/mingw_64/include/QtCore/qatomic.h:8, from C:/Qt/6.6.0/mingw_64/include/QtCore/qrefcount.h:7, from C:/Qt/6.6.0/mingw_64/include/QtCore/qbytearray.h:8, from C:/Qt/6.6.0/mingw_64/include/QtCore/qurl.h:8, from C:/Qt/6.6.0/mingw_64/include/QtQml/qqmlengine.h:7, from C:/Qt/6.6.0/mingw_64/include/QtQml/QQmlEngine:1, from C:/Users/USER/source/repos/testqt2/test.hpp:2, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:9, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\mocs_compilation.cpp:2:C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/type_traits: In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = bool]':C:/Qt/6.6.0/mingw_64/include/QtCore/qtypeinfo.h:320:7: required by substitution of 'template<class Container, class ... T> using compare_eq_result_container = std::enable_if_t<conjunction_v<std::disjunction<std::is_base_of<Container, T>, QTypeTraits::has_operator_equal<T> >...>, bool> [with Container = QList<test_gadget>; T = {test_gadget}]'C:/Qt/6.6.0/mingw_64/include/QtCore/qlist.h:341:56: required by substitution of 'template<class U> QTypeTraits::compare_eq_result_container<QList<test_gadget>, U> QList<test_gadget>::operator!=<U>(const QList<test_gadget>&) const [with U = test_gadget]'C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:211:72: required from hereC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/type_traits:2514:11: error: no type named 'type' in 'struct std::enable_if<false, bool>' 2514 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~In file included from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\mocs_compilation.cpp:2:C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp: In static member function 'static void test_object::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:307:28: error: no match for 'operator!=' (operand types are 'QVector<test_gadget2>' {aka 'QList<test_gadget2>'} and 'QList<test_gadget2>') 307 | if (_t->gadget != *reinterpret_cast< QList<test_gadget2>*>(_v)) { | ~~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | QList<[...]> | QList<[...]>In file included from C:/Qt/6.6.0/mingw_64/include/QtCore/qurl.h:11, from C:/Qt/6.6.0/mingw_64/include/QtQml/qqmlengine.h:7, from C:/Qt/6.6.0/mingw_64/include/QtQml/QQmlEngine:1, from C:/Users/USER/source/repos/testqt2/test.hpp:2, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\EWIEGA46WW/moc_test.cpp:9, from C:\Users\USER\source\repos\build-testqt2-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\apptestqt2_autogen\mocs_compilation.cpp:2:C:/Qt/6.6.0/mingw_64/include/QtCore/qlist.h:341:56: note: candidate: 'template<class U> QTypeTraits::compare_eq_result_container<QList<T>, U> QList<T>::operator!=(const QList<T>&) const [with U = U; T = test_gadget2]' 341 | QTypeTraits::compare_eq_result_container<QList, U> operator!=(const QList &other) const | ^~~~~~~~C:/Qt/6.6.0/mingw_64/include/QtCore/qlist.h:341:56: note: template argument deduction/substitution failed:mingw32-make.exe[2]: *** [CMakeFiles\apptestqt2.dir\build.make:129: CMakeFiles/apptestqt2.dir/apptestqt2_autogen/mocs_compilation.cpp.obj] Error 1mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:98: CMakeFiles/apptestqt2.dir/all] Error 2mingw32-make.exe: *** [Makefile:135: all] Error 213:50:07: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 2.Error while building/deploying project testqt2 (kit: Desktop Qt 6.6.0 MinGW 64-bit)When executing step "Build"
So I tried adding operator!=
to every object so it looks like following:
class test_gadget { Q_GADGET Q_PROPERTY(QString test MEMBER test)public: QString test; bool operator!=(const test_gadget& other) const { return this->test != other.test; }};class test_gadget2 { Q_GADGET Q_PROPERTY(QVector<test_gadget> testo MEMBER testo)public: QVector<test_gadget> testo; bool operator!=(const test_gadget2& other) const { // error: no match for 'operator!=' (operand types are 'QVector<test_gadget>' {aka 'QList<test_gadget>'} and 'QList<test_gadget>') return this->testo != other.testo; }};class test_object : public QObject { Q_OBJECT Q_PROPERTY(QVector<test_gadget2> gadget MEMBER gadget)public: test_object(const test_gadget2& g);private: QVector<test_gadget2> gadget;};
However, the issues persist. How should I fix this issue?