Hi everybody,

I have been frustrated due to a problem I could not solve. Hope you can help me. I could not find a source which would make be able to overcome it.

I have created a class which inherits QTreeWidgetItem. I want to implement custom signals and slots. When I do that I am receiving following error.

Qt Code:
  1. Class declarations lacks Q_OBJECT macro.
To copy to clipboard, switch view to plain text mode 

As far as I know the QTreeWidgetItem class inherits QWidget which inherits QObject so Q_OBJECT macro should not be used in my class. Just out of curiosity i added Q_OBJECT macro too see what happens and I had lots of C2440, C2039, C2664, C2665, etc.

Somehow I am not able to see available signals and slots on my class when I type connect function somewhere else. I also cannot use connect function inside my class since QObject is not related to my class.

Here is my class


Qt Code:
  1. #ifndef ETREEWIDGETITEM_H
  2. #define ETREEWIDGETITEM_H
  3.  
  4. #include <QTreeWidgetItem>
  5. #include "en.h"
  6.  
  7. class ETreeWidgetItem : public QTreeWidgetItem
  8. {
  9.  
  10. public:
  11. explicit ETreeWidgetItem(En &en, QTreeWidget *parent=0);
  12.  
  13. explicit ETreeWidgetItem(En &en, QTreeWidgetItem *parent, int type = Type);
  14.  
  15. void updateText(void);
  16.  
  17. void clearChildren(void);
  18.  
  19. En en;
  20.  
  21.  
  22.  
  23. signals:
  24. void enHasChangedSignal();
  25.  
  26. public slots:
  27.  
  28. void enHasChanged();
  29.  
  30. };
  31.  
  32. #endif
To copy to clipboard, switch view to plain text mode 


could anyone help me about it? Thanks a lot in advance.