I have the following example in Qt in which I am trying to redefine the keyPressEvent subclass of QTextEdit, but gives me a "plural definition of txt :: keyPressEvent (QKeyEvent *)", and I cannot understand why:
//txt.h #ifndef TXT_H #define TXT_H #include <QTextEdit> class txt : public QTextEdit { Q_OBJECT public: txt(QWidget *parent = 0); signals: void keyPressEvent(QKeyEvent *e); public slots: }; #endif // TXT_H //txt.cpp #include "txt.h" txt::txt(QWidget *parent) : QTextEdit(parent) { } void txt::keyPressEvent(QKeyEvent *e){ //do stuff with the key event } //main.cpp #include <QtGui/QApplication>
I tried scrolling the QTextEdit declaration in txt.h and #, including it only in cpp, but this gives me some other errors (maybe because I need a class in the header, so how do I subclass it?)
Anyway, what am I doing wrong?
EDIT: I also tried it with another class (QLabel) and now I get the same error ...
source share