Add a signal in class that inherited from The QplainTextEdit



  • I have this class that inherited from QplainTextEdit and I Want to implement a signal function this is the class

    #ifndef PLAINTEXTEDIT_H
    #define PLAINTEXTEDIT_H
    
    #include <QPlainTextEdit>
    #include <QDebug>
    #include <QObject>
    
    class PlainTextEdit : public QPlainTextEdit
    {
      Q_OBJECT
    public:
      PlainTextEdit(QWidget *parent=0);
    
      bool event(QEvent *event);
    signals:
      void CursorChange(int n);
    public:
      void SetString(QString s);
    private:
      QString str;
    };
    

    but i got many undefined reference pointing to function constructor and emit signal part first I got an error so I add the Q_OBJECT to the class but when i add it i got this error


  • Qt Champions 2016

    @AmrCoder

    Hi
    I don't see any errors?
    If you want help to resolve errors we need the actual errors shown :)



    • Did you re-run qmake after adding Q_OBJECT?
    • do you have a .cpp file with implementations?


  • @AmrCoder
    hi,

    without seeing the actual error messages, I would suggest adding

    #include <QWidget>
    #include <QEvent>
    

    also could you show us the constructor in your cpp file?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.