[Interest] Re: How to add tidy using Qt?

Jan Kundrát jkt at flaska.net
Thu Dec 27 12:22:39 CET 2012


On Thursday, 27 December 2012 09:40:12 CEST, 程梁 wrote:
> But could you tell me why this happen? Why I have to assign QByteArray to 
> another variable?

From the QByteArray::constData's documentation: "The pointer remains valid as long as the byte array isn't reallocated or destroyed.". If you don't store the QByteArray into a variable, the temporary is destroyed immediately.

> And why only the content is wrong?

Because you were lucky. It is not allowed to access memory in such a way in C++.

Cheers,
Jan

-- 
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/



More information about the Interest mailing list