[Interest] Is moc obsolete?
André Somers
andre at familiesomers.nl
Thu Jul 9 07:23:28 CEST 2015
Elvis Stansvik schreef op 8-7-2015 om 22:51:
>
> Perhaps not related to the question discussed here, but what I've
> actually missed sometimes is to be able to make a class template that
> is also a QObject (including Q_OBJECT macro). I'm not sure moc can
> handle that, at least not fully. If moc needs to improve, I think
> that's one of the things that would be nice if it could support. I
> believe there was even a patch for that floating around at some point
> (can't find a link at the moment), but I think it needed more work and
> was rejected.
You can do that, but only indirectly. You cannot make a template class
that direcly inherits and extends QObject. However, you can make a
template class that inherits a class that inherits and extends QObject.
Basicaly the only thing you cannot do with that construction is have
signals and slots depend on your template parameter. Note that you can
also make the class the template inherits from a template argument
itself, so you really have quite a few options to work with. Still,
_sometimes_ it would be _nice_ if it would just work directly. However,
you probably shouldn't need it much, and it is not that hard to work
around.
André
More information about the Interest
mailing list