Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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


  • Lifetime Qt Champion

    @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?

  • Moderators

    @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