Skip to content
  • 0 Votes
    4 Posts
    5k Views
    VRoninV

    @c64zottel said in How to use Q_DISABLE_COPY( class ) without ctor?:

    The ctor is simply empty

    It is not. in fact it calls the QObject constructor that does a lot of stuff. removing it while leaving the Q_DISABLE_COPY prevents the compiler from creating a default constructor (which would be wrong anyway).

    Now we have 2 possible solutions:

    If your InputDeviceConfigurator uses signals and slots or defines properties then your only choice is to explicitly declare the constructor and pass the parent explicit InputDeviceConfigurator(QObject *parent = Q_NULLPTR) : QObject(parent){} if InputDeviceConfigurator does not uses signals and slots nor defines properties then lose the QObject inheritance altogether and use multiple inheritance for the derived classes.

    Just to make the point clear: you don't "remove the constructor". see this table

    @c64zottel said in How to use Q_DISABLE_COPY( class ) without ctor?:

    the auto generate ctor would be fine too.

    In cases (this one is not one of them) in which the default costructor is what you want just use =default