Is that possible to put QSting in to QBytearray?
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!
QString addr = "55:55:55:55:55:55"; QBytearray pair = QByteArray("pair ")+addr.toUtf8()+QByteArray("\n");
Given all your string is ASCII-representable:
The answer is @raven-worx is also correct, the only note is that I'd use
QByteArrayLiteral("pair ")instead of
QByteArray("pair ")as some compilers can optimise that better