[Merged] How to instantiate another QByteArray from and existing array?
-
wrote on 21 Oct 2010, 22:21 last edited by
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!
-
wrote on 21 Oct 2010, 22:40 last edited by
@
QByteArray other("white");
other = ba;
@ -
wrote on 21 Oct 2010, 22:45 last edited by
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.
-
wrote on 21 Oct 2010, 22:47 last edited by
sorry...
-
wrote on 21 Oct 2010, 22:51 last edited by
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?
-
wrote on 21 Oct 2010, 23:05 last edited by
@
bb = ba.right(4);
@The size is handled internally. If you really want to, you can call bb.squeeze(), but that's hardly necessary.
-
wrote on 22 Oct 2010, 07:24 last edited by
Denis: I merged the topics.
-
wrote on 22 Oct 2010, 08:57 last edited by
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.
-
wrote on 22 Oct 2010, 14:49 last edited by
thank you all!
1/9