Is QByteArray::setRawData() , are bytes copied or not? I do now know very well the difference beteen test1() and test2() function listed below. :(




[source]


void test1()
{
  char buf[] = "abcde";
  QByteArray ba;
  ba.setRawData(buf, sizeof(buf) - 1);
  buf[0] = 'A';
  qDebug() << buf;
  qDebug() << ba;
}

void test2()
{
  char buf[] = "abcde";
  QByteArray ba;
  ba.setRawData(buf, sizeof(buf) - 1);
  ba[0] = 'A';
  qDebug() << buf;
  qDebug() << ba;
}

int main()
{
  test1();
  test2();
  return 0;
}




[run]


Abcde

"Abcde"

abcde

"Abcde"




[download]

qbytearray_test.zip