[英]How can I convert QByteArray to QString with separator '-'?
I'm new in Qt and can't find any solution in Qt libraries. 我是Qt的新手,在Qt库中找不到任何解决方案。
I'd like to find smth without loop usage. 我想找到没有循环用法的smth。
Is there any way to convert QByteArray
to QString
with -
between bytes? 有什么方法可以将
QByteArray
转换为QString
并在字节之间使用-
For example: 例如:
QByteArray = XX1F2C5A
QString = "XX-1F-2C-5A".
Yeah you can with QString::replace : 是的,您可以使用QString :: replace :
QByteArray b = "XX1F2C5A";
QString s(b);
qDebug() << s;
s.replace(QRegExp("(..)[^$]"), QString("\\1-"));
qDebug() << s;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.