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. connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48

connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.9k 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.
  • L Offline
    L Offline
    Lavanya
    wrote on last edited by
    #1

    I am recently started coding for serialport communication where i taken refererence of qtserialport terminal example code and there another console class is taken where i haven't taken that instead i directly trying to use qplaintextedit in ui file . where i am getting read data properly but writing is nit getting so there in connect method i did this way.
    in serial.h file:
    QPlainTextEdit *console.
    in serial.cpp
    console=new QPlainTextEdit ()
    connect(console, SIGNAL(textChanged(QByteArray&)), this, SLOT(writeData(QByteArray)));
    by using this way when compiled i am getting this message on desktop.
    connect: No such signal QPlainTextEdit::textChanged(QByteArray&)
    why iam getting this is the way i am using is correct?
    are like readyread any default signals for QPlianTextEdit class to write in to textbox and create a connection to slot methos .

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Lavanya
      wrote on last edited by
      #13

      Thank you all for your support .
      Somehow i managed in completing the application using emiting signal from a keypressevent method. it worked for me with little condition that until we keep cursor in plaintextedit box it will continue writing but once if we place the cursor it is failng to write and then it works normal as plaintextedit where only we can write in to box but cannot write to serialport
      I am working on it how to solve so as of now for these i am closing this belt as solved

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #2

        Because textChanged signal doesn't has a QByteArray as parameter.
        And the problem here is not that QPlainTextEdit doesn't have a "readyRead" signal, but it doesn't have a "read"-like function to read the "unread" data.
        If you use a QPlainTextEdit instead of a console, you'll need to detect what has changed by your own.

        If this is my project, I think I would use a read-only QPlainTextEdit just as a history viewer, and a QLineEdit as input, connecting its returnPressed signal.

        1 Reply Last reply
        4
        • L Offline
          L Offline
          Lavanya
          wrote on last edited by
          #3

          Thank you Bonnie for your reply.
          So You mean to say that i cannot use QByteArray as a parameter in PlainTextEdit. so can i use this way connect(ui->PlainTextEdit,SIGNAL(textChanged(QString)),this,SLOT(writeData(QByteArray)))?
          this also gives as this way
          No such signal is coming.
          As you said how to use line edit along with plaintextedit.
          OR
          is there any way to add custom signals created to Qplaintextedit class.
          OR
          can i use source object of widget and signal of custom signal we are emiting
          like this way :
          connect(ui->plainTextEdit,SIGNAL(Serial::getData()),this,SLOT(writeData(QByteArray)));

          JKSHJ 1 Reply Last reply
          0
          • L Lavanya

            Thank you Bonnie for your reply.
            So You mean to say that i cannot use QByteArray as a parameter in PlainTextEdit. so can i use this way connect(ui->PlainTextEdit,SIGNAL(textChanged(QString)),this,SLOT(writeData(QByteArray)))?
            this also gives as this way
            No such signal is coming.
            As you said how to use line edit along with plaintextedit.
            OR
            is there any way to add custom signals created to Qplaintextedit class.
            OR
            can i use source object of widget and signal of custom signal we are emiting
            like this way :
            connect(ui->plainTextEdit,SIGNAL(Serial::getData()),this,SLOT(writeData(QByteArray)));

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #4

            @Lavanya said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

            so can i use this way connect(ui->PlainTextEdit,SIGNAL(textChanged(QString)),this,SLOT(writeData(QByteArray)))?

            You cannot. See https://doc.qt.io/qt-5/signalsandslots-syntaxes.html

            The important points are:

            • When you connect using the SIGNAL() and SLOT() macros, the datatypes must match exactly. You cannot use this to connect an int signal to a double slot.
            • When you connect using function pointers, the datatypes can be different -- as long as the signal datatype can be automatically converted to the slot datatype. You can use this to connect an int signal to a double slot.
            • QString cannot be automatically converted to a QByteArray, so there is no way to connect a QString signal to a QByteArray slot.

            What you can do instead is connect the signal to a lambda function:

            connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                this->writeData(newText.toUtf8());
            });
            

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            B 1 Reply Last reply
            4
            • L Offline
              L Offline
              Lavanya
              wrote on last edited by
              #5

              If i am creating a object to QPlainTextEdit and creating new to that in cpp file and calling that object directly in connect method is giving me like this.
              QObject::connect: Incompatible sender/receiver arguments
              well which is not case if i used ui->plaintextedit in connect?
              Anybody can tell me about this?

              jsulmJ 1 Reply Last reply
              0
              • L Lavanya

                If i am creating a object to QPlainTextEdit and creating new to that in cpp file and calling that object directly in connect method is giving me like this.
                QObject::connect: Incompatible sender/receiver arguments
                well which is not case if i used ui->plaintextedit in connect?
                Anybody can tell me about this?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @Lavanya Please show your code, it is hard to understand what you mean.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • JKSHJ JKSH

                  @Lavanya said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                  so can i use this way connect(ui->PlainTextEdit,SIGNAL(textChanged(QString)),this,SLOT(writeData(QByteArray)))?

                  You cannot. See https://doc.qt.io/qt-5/signalsandslots-syntaxes.html

                  The important points are:

                  • When you connect using the SIGNAL() and SLOT() macros, the datatypes must match exactly. You cannot use this to connect an int signal to a double slot.
                  • When you connect using function pointers, the datatypes can be different -- as long as the signal datatype can be automatically converted to the slot datatype. You can use this to connect an int signal to a double slot.
                  • QString cannot be automatically converted to a QByteArray, so there is no way to connect a QString signal to a QByteArray slot.

                  What you can do instead is connect the signal to a lambda function:

                  connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                      this->writeData(newText.toUtf8());
                  });
                  
                  B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by
                  #7

                  @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                  connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                  this->writeData(newText.toUtf8());
                  });

                  Since void QPlainTextEdit::textChanged() have no parameter at all, I think that cannot be done either...

                  JKSHJ 1 Reply Last reply
                  2
                  • B Bonnie

                    @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                    connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                    this->writeData(newText.toUtf8());
                    });

                    Since void QPlainTextEdit::textChanged() have no parameter at all, I think that cannot be done either...

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #8

                    @Bonnie said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                    @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                    connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                    this->writeData(newText.toUtf8());
                    });

                    Since void QPlainTextEdit::textChanged() have no parameter at all, I think that cannot be done either...

                    Oops, good spot.

                    Easily fixed:

                    connect(console, &QPlainTextEdit::textChanged, [console, this] {
                        this->writeData( console->text().toUtf8() );
                    });
                    

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    B 1 Reply Last reply
                    3
                    • JKSHJ JKSH

                      @Bonnie said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                      @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                      connect(console, &QPlainTextEdit::textChanged, [this](const QString &newText) {
                      this->writeData(newText.toUtf8());
                      });

                      Since void QPlainTextEdit::textChanged() have no parameter at all, I think that cannot be done either...

                      Oops, good spot.

                      Easily fixed:

                      connect(console, &QPlainTextEdit::textChanged, [console, this] {
                          this->writeData( console->text().toUtf8() );
                      });
                      
                      B Offline
                      B Offline
                      Bonnie
                      wrote on last edited by
                      #9

                      @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                      connect(console, &QPlainTextEdit::textChanged, [console, this] {
                      this->writeData( console->text().toUtf8() );
                      });

                      Yes! But the problem is that it will always write the full text of the QPlainTextEdit whenever there's any change.
                      This is what I said about QPlainTextEdit doesn't have a "read"-like function...

                      JKSHJ 1 Reply Last reply
                      1
                      • B Bonnie

                        @JKSH said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                        connect(console, &QPlainTextEdit::textChanged, [console, this] {
                        this->writeData( console->text().toUtf8() );
                        });

                        Yes! But the problem is that it will always write the full text of the QPlainTextEdit whenever there's any change.
                        This is what I said about QPlainTextEdit doesn't have a "read"-like function...

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by
                        #10

                        @Bonnie said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                        But the problem is that it will always write the full text of the QPlainTextEdit whenever there's any change.

                        No arguments there. Nonetheless, I'd say that understanding how to use QObject::connect() is more fundamental -- OP will still face the same error messages even with QLineEdit.

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          Lavanya
                          wrote on last edited by
                          #11

                          So more or less i have to create one more class and define a signal in that class and then create a object to that class in mainwindow class and write it in connect method . I hope this way only it seems to work with out creating too many classes in application i wanted to use directly but it creating a problem.
                          Nonetheless, I'd say that understanding how to use QObject::connect()
                          Yes i do understand but trying to create use QPlainTextEdit for writing to serial port directly and for that i am trying to use connect method to create a connection between Qplaintextedit widget object to serial port writedata method slot.
                          Which is very clear in my understanding but problem comes in using proper signal only. i didn't find proper signal for Qplaintextedit when something written totextedit create a connection to serialport write data.

                          jsulmJ 1 Reply Last reply
                          0
                          • L Lavanya

                            So more or less i have to create one more class and define a signal in that class and then create a object to that class in mainwindow class and write it in connect method . I hope this way only it seems to work with out creating too many classes in application i wanted to use directly but it creating a problem.
                            Nonetheless, I'd say that understanding how to use QObject::connect()
                            Yes i do understand but trying to create use QPlainTextEdit for writing to serial port directly and for that i am trying to use connect method to create a connection between Qplaintextedit widget object to serial port writedata method slot.
                            Which is very clear in my understanding but problem comes in using proper signal only. i didn't find proper signal for Qplaintextedit when something written totextedit create a connection to serialport write data.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            @Lavanya said in connect: No such signal QPlainTextEdit::textChanged(QByteArray&) in serial.cpp:48:

                            i have to create one more class and define a signal in that class and then create a object to that class

                            Why do you think so?
                            This was the suggestion from @JKSH :

                            connect(console, &QPlainTextEdit::textChanged, [console, this] {
                                this->writeData( console->text().toUtf8() );
                            });
                            

                            I don't see any new classes/signals here...

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            2
                            • L Offline
                              L Offline
                              Lavanya
                              wrote on last edited by
                              #13

                              Thank you all for your support .
                              Somehow i managed in completing the application using emiting signal from a keypressevent method. it worked for me with little condition that until we keep cursor in plaintextedit box it will continue writing but once if we place the cursor it is failng to write and then it works normal as plaintextedit where only we can write in to box but cannot write to serialport
                              I am working on it how to solve so as of now for these i am closing this belt as solved

                              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