Q_OBJECT and moc for inheritance

I work in a project where the Q_OBJECT macro is used in a class that I need to inherit.

The class in which Q_OBJECT is already defined looks like this:

class cBaseObject : public QObject, public cinformation
{
    Q_OBJECT
    //...
    //...
}

I am creating a new class through cBaseObject public inheritance. Should I write the Q_OBJECT macro again? I tried with and without this macro, and I see that the moc_XXX.cxx file is not created unless I include QT_MACRO

class cEnhancedbaseObject : public cBaseObject
{
    Q_OBJECT   // if i didn't include this 
          //no moc__XXX.cxx file is  generated
} 

But when I inherit the class, why the functionality of the Q_OBJECT macro is also not inherited. Is this a problem if the Q_OBJECT macro is defined twice, if it is inherited? Like the Q_OBJECT behavior for multi-level inheritance. I read that for multiple inheritance, the QOBJECT class must be selected first. Is there something similar for multi-level inheritance.

+4
1

Q_OBJECT - Qt. , , Q_OBJECT ( , QObject, ).

cBaseObject cEnhancedbaseObject, cEnhancedbaseObject Q_OBJECT, . , - Qt , cEnhancedbaseObject - cBaseObject. , , myObject->metaObject()->className().

+2

Source: https://habr.com/ru/post/1619056/


All Articles