Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Add a signal in class that inherited from The QplainTextEdit

Add a signal in class that inherited from The QplainTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 747 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AmrCoderA Offline
    AmrCoderA Offline
    AmrCoder
    wrote on last edited by A Former User
    #1

    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

    mrjjM J.HilkJ 2 Replies Last reply
    0
    • AmrCoderA AmrCoder

      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

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AmrCoder

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

      1 Reply Last reply
      6
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3
        • Did you re-run qmake after adding Q_OBJECT?
        • do you have a .cpp file with implementations?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        3
        • AmrCoderA AmrCoder

          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

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

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


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved