Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved Add a signal in class that inherited from The QplainTextEdit

    General and Desktop
    4
    4
    390
    Loading More Posts
    • 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.
    • AmrCoder
      AmrCoder last edited by A Former User

      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

      mrjj J.Hilk 2 Replies Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion @AmrCoder last edited by

        @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 Reply Quote 6
        • V
          VRonin last edited by

          • 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 Reply Quote 3
          • J.Hilk
            J.Hilk Moderators @AmrCoder last edited by

            @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

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

            1 Reply Last reply Reply Quote 3
            • First post
              Last post