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".
Yeah you can with QString::replace :
QByteArray b = "XX1F2C5A";
QString s(b);
qDebug() << s;
s.replace(QRegExp("(..)[^$]"), QString("\\1-"));
qDebug() << s;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.