Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Is that possible to put QSting in to QBytearray?
victor wang last edited by victor wang
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");
VRonin last edited by VRonin
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