Reputation: 126
I'm new in Qt and can't find any solution in Qt libraries.
I'd like to find smth without loop usage.
Is there any way to convert QByteArray
to QString
with -
between bytes?
For example:
QByteArray = XX1F2C5A
QString = "XX-1F-2C-5A".
Upvotes: 1
Views: 1056
Reputation: 8560
Yeah you can with QString::replace:
QByteArray b = "XX1F2C5A";
QString s(b);
qDebug() << s;
s.replace(QRegExp("(..)[^$]"), QString("\\1-"));
qDebug() << s;
Upvotes: 2