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. Subclassed QPlainTextEdit, how can call in other class?
Forum Updated to NodeBB v4.3 + New Features

Subclassed QPlainTextEdit, how can call in other class?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 2.6k Views 1 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #2

    It's RepairDevices that has to connect to notifierText not the other way around

    "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
    2
    • P Offline
      P Offline
      Panoss
      wrote on last edited by Panoss
      #3

      I did it like this in RepairDevices constructor:
      connect(ui.sn_txt,SIGNAL(textChanged(QString)),this,SLOT(setDirty(QString)));

      But I get a warning:
      QObject::connect: No such signal QPlainTextEdit::textChanged(QString)

      And it's not working.
      What am I doing wrong?

      mrjjM 1 Reply Last reply
      0
      • P Panoss

        I did it like this in RepairDevices constructor:
        connect(ui.sn_txt,SIGNAL(textChanged(QString)),this,SLOT(setDirty(QString)));

        But I get a warning:
        QObject::connect: No such signal QPlainTextEdit::textChanged(QString)

        And it's not working.
        What am I doing wrong?

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

        @Panoss
        Hi
        Does notifierText have a Q_OBJECT macro ?

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Panoss
          wrote on last edited by
          #5

          Hi mrjj.
          I demoted it to QPlainTextEdit, I don't use the notifierText class.

          mrjjM 1 Reply Last reply
          0
          • P Panoss

            Hi mrjj.
            I demoted it to QPlainTextEdit, I don't use the notifierText class.

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

            @Panoss
            Hi :)
            ok so sn_txt is now a 100% normal QPlainTextEdit and not your class?
            Did you clean, rebuild all after changing back?

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Panoss
              wrote on last edited by
              #7

              Yes it 's a pure QPlainTextEdit .
              I cleaned and rebuild but the same happens.

              mrjjM 1 Reply Last reply
              0
              • P Panoss

                Yes it 's a pure QPlainTextEdit .
                I cleaned and rebuild but the same happens.

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

                @Panoss
                show the new current code then.
                It normally just works.

                1 Reply Last reply
                1
                • P Offline
                  P Offline
                  Panoss
                  wrote on last edited by Panoss
                  #9

                  This is the connection in RepairDevices' constructor:

                  connect(ui.sn_txt,SIGNAL(textChanged(QString)),this,SLOT(setDirty(QString)));
                  

                  This is the declaration of the function:

                  public slots:
                      void setDirty(QString txt);
                  

                  This is the function:

                   void RepairDevices::setDirty(QString txt)
                   {
                       qDebug() << "text=" << txt;   
                   }
                  
                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Panoss
                    wrote on last edited by Panoss
                    #10

                    When I change to textChanged(), it works.
                    But I don't have the text of the sn_txt.

                    And I see here: void QPlainTextEdit::textChanged()

                    mrjjM 1 Reply Last reply
                    0
                    • P Panoss

                      When I change to textChanged(), it works.
                      But I don't have the text of the sn_txt.

                      And I see here: void QPlainTextEdit::textChanged()

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

                      @Panoss said in Subclassed QPlainTextEdit, how can call in other class?:

                      textChanged

                      i dont think it has version where it emits the whole text. lineEdit has.

                      so you must use QPlainTextEdit::textChanged() and

                      void RepairDevices::setDirty()
                      {
                      qDebug() << "text=" << ui->plaintext->toPlainText();
                      }

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Panoss
                        wrote on last edited by Panoss
                        #12

                        The reason I subclassed it, was because I wanted the class to connect to RepairDevices 's slot.
                        (that is, the code: connect blah blah to be in the class)
                        This is not possible, so it's canceled.
                        Thank you for your help.

                        mrjjM 1 Reply Last reply
                        0
                        • P Panoss

                          The reason I subclassed it, was because I wanted the class to connect to RepairDevices 's slot.
                          (that is, the code: connect blah blah to be in the class)
                          This is not possible, so it's canceled.
                          Thank you for your help.

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

                          @Panoss

                          Well the normal signal does not have QString but in a subclass
                          you could easy make a new signal that would have and
                          then emit it in the subclass and it would be as you wanted.

                          1 Reply Last reply
                          0

                          • Login

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