Data loss while converting from QString to string
Samael_00001 last edited by Samael_00001
QString output = ui->textEdit_2->toPlainText();
string text = output.toUtf8().constData();
Rondog last edited by
QString can handle having an embedded null character (0x00) whereas C strings would treat this a terminator. I can't tell from your screenshot but likely the character where it is truncated is a null byte.
Probably the data is lost when you construct the std::string as constData() returns a pointer to char. You should use the method toStdString() instead.
I am not sure if std::string can contain a null character but I suspect it can.