Delay between characters write to serial port

  • Hi,

    I want to send printable ascii characters from 32 to 126 (converted to string) to the serial port with a delay between each character. when start button is pressed the SendHandle () function is called. I want to send the ascii characters continuously with delay between each character. I have written a code as below but it hangs when i click the start button. Please help me in this regard.

    void Widget::SendHandle ()

          QString str1= QChar(i);
          asc =str1.toUtf8();
        serial->write(asc); //writing data to serial port
        ui->display->moveCursor (QTextCursor::End);
        ui->display->insertPlainText (asc);
        ui->display->moveCursor (QTextCursor::End);


  • if you sleep in the GUI code
    complete event engine is not called
    so the GUI freezes
    you can implement code by using signals & slots


    you can call event engine using
    to process the events

  • Thank you so much. QCoreApplication::processEvents(); worked ....

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.