QT : Templated Q_OBJECT class

后端 未结 4 752
予麋鹿
予麋鹿 2020-11-29 03:26

Is it possible to have a template class, which inherit from QObject (and has Q_OBJECT macro in it\'s declaration)?

I would like to create something like adapter for

4条回答
  •  迷失自我
    2020-11-29 03:46

    I tried explicitly instantiating templates, and got this :

    core_qta_qt_publisheradapter.hpp:96: Error: Template classes not supported by Q_OBJECT

    I guess that answers my question.

    EDIT

    Actually, if I place whole template class definition in the header, then the qt preprocessor doesn't process it, and then I get linker errors. Therefore it must be possible to do it, if I add missing methods.

    EDIT #2

    This library did exactly what I wanted - to use a custom signal/slot mechanism, where the slot has not-defined signature.

提交回复
热议问题