You don't need to specify the size of the byte array if you use QByteArray, that was my whole point. Here is your code using QByteArray and proper for loop bounds:
int size = list1.size();
for (int i=0; i < size; i++){
bool ok;
senddata[i]=ran.toInt(&ok,16);
}
serial->write(senddata.constData(), senddata.length());
QString input = ui->data->text();
QStringList list1 = input.split(",");
int size = list1.size();
QByteArray senddata;
for (int i=0; i < size; i++){
QString ran = list1 [i];
bool ok;
senddata[i]=ran.toInt(&ok,16);
}
serial->write(senddata.constData(), senddata.length());
To copy to clipboard, switch view to plain text mode
Bookmarks