Your code has lots of problems:
char *testarr = new char[15];
QByteArray br
= strVal1.
toUtf8();
// why? you could use simply QByteArray br("Test"); avoiding some unnecessary conversions. testarr = br.data(); // here you have memory leak, you are loosing touch with block you allocated in first line, by overriding it with value form QByteArray
delete[] testarr; // now you are deleting something what is owned by `br`
char *testarr = new char[15];
QString strVal1="Test";
QByteArray br = strVal1.toUtf8(); // why? you could use simply QByteArray br("Test"); avoiding some unnecessary conversions.
testarr = br.data(); // here you have memory leak, you are loosing touch with block you allocated in first line, by overriding it with value form QByteArray
delete[] testarr; // now you are deleting something what is owned by `br`
To copy to clipboard, switch view to plain text mode
Bookmarks