You are doing a double conversion there, potentially lossy.

First you encode the QString returned by toPlainText() with the 8-bit codec used for local encoding (toLocal8Bit()), then you convert back to QString using UTF-8 (when assigning to the QString variable).

If your low-level API required a char*, then first get the encoded form as a QByteArray and then send its constData().

E.g.
Qt Code:
  1. const QByteArray data = ui->MotorCommandText->toPlainText().toLocal8Bit();
  2. low_level_write(data.constData(), data.size());
To copy to clipboard, switch view to plain text mode 

Cheers,
_