First of all - you should really use QtSerialPort
Second of all - QString
is a class, which works with actual string. QByteArray
works with raw data. When you write QString line = in.readAll();
it implicitly calls QString(const QByteArray &ba)
, which uses QString::fromAscii
.
Last of all, if you want to process 64bit integers, you should do something like this:
quint64 d;
QDataStream stream(&file);
while (!stream.atEnd())
{
stream >> d;
process(d);
}
Update
Quote:
My problem is that in plainTextEdit "1111110101000101010101010101010101010101010101010101010......." 64 bit data is populated , i need to convert this data into hex and send it through rs232
Solution:
QString binData = plainTextEdit.toPlainText();
QByteArray result;
while (binData.size() >= 64)
{
quint64 d;
QString dataPiece = binData.left(64);
binData.remove(0, 64);
d = dataPiece.toULongLong(0, 2);
result += QByteArray::number(d);
}
_com->write(result);
_com->flush();
Where _com
is a pointer to QtSerialPort
, with all parameters set and opened without errors.