template class not supported by Q_OBJECT
- // -- header file -------------------------------------------
- #ifndef MY_CLASS_C_H
- #define MY_CLASS_C_H
- #include <QObject>
- template <typename MY_TYPE>
- {
- Q_OBJECT
- public:
- signals:
- public slots:
- };
- #endif // MY_CLASS_C_H
- // -- source file --------------------------------------------
- #include "my_class_c.h"
- template <typename MY_TYPE>
- {
- }
- // -- compiler output ---------------------------------
- my_class_c.h:9: Error: Template classes not supported by Q_OBJECT
can anyone tell me where exactly i am making mistake.???
[Edit] Please use code wrapping tags [developer.qt.nokia.com]
8 replies
Then, you are out of luck. The only thing you can do then, is wrap the type in a QVariant and emit the signal or define the slot based on the QVariant from the baseclass again. Or, you don’t emit the actual value, and let clients call a normal getter method in response to a changed signal instead of sending the value directly. You simply cannot define signals and slots in a template class.
You must log in to post a reply. Not a member yet? Register here!




