Answer the question
In order to leave comments, you need to log in
How to make Q_PROPERTY in interface without inheriting from QObject?
Greetings!
In general, I really want to do something so that Q_PROPERY signals and slots can be moved to interfaces.
There were almost no problems with signals and slots and they came out fine,
but Q_PROPERTY does not want to.
Namely, the moc file does not want to be generated if there is no Q_OBJECT or Q_GADGET
, if prescribed, then Qt starts swearing that the class should be inherited from QObject.
I tried to manually edit moc_*.cpp and managed to get Q_PROPERTY to work normally, but of course, when recompiling, all changes in the moc file are wiped out and making a separate moc is, in my opinion, a hell of a crutch.
Inheriting an interface from QObject is not an option - in the future there may be multiple inheritance and it may turn out that there will be inheritance from several QObjects, which Qt will swear at.
Tell me how to make it so that Q_PROPERTY could be declared in the interface? Or maybe you can somehow redefine the operation of the moc generator (prohibit the generation of staticMetaObject) without rebuilding it from raw ones.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question