[Merged] How to instantiate another QByteArray from and existing array?
-
For instance:
QByteArray ba(" lots\t of\nwhitespace\r\n ");I want to most effective what to instantiate and resize another QByteArray with value ¨white¨ from ba.
Thanks!
-
@
QByteArray other("white");
other = ba;
@ -
Hm. This category is not for dev questions. It is only for questions about using Qt in education methods (i.e. in universities or via seminars). Your first question was merged with another one and stayed in Desktop category because Desktop category fits your question, not this one.
2Someone who has rights in this category: merge it with one in Destop, please.
-
sorry...
-
For instance,
I have a QByteArray ba(¨This is a test¨);
I have another QByteArray bb;How can I copy the word ¨test¨ from ba to bb and have it instantiate as well as resize the bb variable?
-
@
bb = ba.right(4);
@The size is handled internally. If you really want to, you can call bb.squeeze(), but that's hardly necessary.
-
Denis: I merged the topics.
-
Note that the copy in itself is cheap. Only if you start modifying your copy will the actual memory be copied. QByteArray is an implicitly shared class.
-
thank you all!