Unsolved Is that possible to put QSting in to QBytearray?
-
Hi All,
I'm using qt5.5 and Linux+QT for my OS system.
This is my program.QString addr = "55:55:55:55:55:55"; QByteArray pair("pair "+addr+"\n");
Can I just put in like this?
If can't then how can I do something like this?Thanks in Advanced!
-
@victor-wang said in Is that possible to put QSting in to QBytearray?:
QString addr = "55:55:55:55:55:55"; QBytearray pair = QByteArray("pair ")+addr.toUtf8()+QByteArray("\n");
-
Given all your string is ASCII-representable:
"pair "+addr.toLatin1()+"\n"
EDIT:
The answer is @raven-worx is also correct, the only note is that I'd useQByteArrayLiteral("pair ")
instead ofQByteArray("pair ")
as some compilers can optimise that better