A custom class, a copy constructor and a warning



  • Hello everyone,

    I'm currently in the process of cleaning up my code and I stumbled over a particular compiler warning:

    base class 'class QObject' should be explicitly initialized in the copy constructor
    Datagram::Datagram(const Datagram &data)
    

    I only have QObject as a base class, to define enums in it and to register is as a Metaobject.
    I need to pass it around via Signal&Slots and a QueuedConnection.

    I do not explicitly initalize QObject in the different constructors either.

    The warning is only there with the mingw-compiler, msvc and clang have no problems with it.

    So how would I do that?

    heres my copy constructor:

    Datagram::Datagram(const Datagram &data)
    {
        m_data = data.m_data;
        m_Type = data.m_Type;
    }
    


  • I only have QObject as a base class, to define enums in it and to register is as a Metaobject.

    That's what Q_GADGET is for. Remove the base class and replace Q_OBJECT with Q_GADGET



  • @VRonin Well apparently it is oO.
    Wasn't ware of that one, I came by it when googled the warning, but gave it not much mind.

    Thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.