Using custom type in Q_PROPERTY
Unsolved
General and Desktop
-
I want to use custom type in Q_PROPERTY MEMBER. Please check out my below code.
header.h
class Custom { Q_GADGET Q_PROPERTY(int mode MEMBER mode STORED true) public: Custom(); int mode; }; class Test { Q_GADGET Q_PROPERTY(QString ip MEMBER ip STORED true) Q_PROPERTY(Custom discovery MEMBER discovery STORED true) public: Test(); QString ip; Custom discovery; }; Q_DECLARE_METATYPE(Custom) Q_DECLARE_METATYPE(Test)
main.cpp
#include "header.h" Test::Test() { qRegisterMetaType<Test>("Test"); } Custom::Custom() { qRegisterMetaType<Custom>("Custom"); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Test reg; return a.exec(); }
when I compile the above code it throws below error
/home/venkat/Documents/test/testing/build-test-Desktop_Qt_5_12_4_GCC_64bit-Debug/moc_CustomeTypes.cpp:175: error: no match for ‘operator!=’ (operand types are ‘Custom’ and ‘Custom’) moc_CustomeTypes.cpp:175:31: error: no match for ‘operator!=’ (operand types are ‘Custom’ and ‘Custom’) if (_t->discovery != *reinterpret_cast< Custom*>(_v)) { ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
should I need to provide operator!= for Custom type ?