[Interest] FW: [External] QByteArray vs QString, arg, why is there no arg()?

Kristoffersen, Even (NO14) Even.Kristoffersen at Honeywell.com
Wed Sep 18 16:25:34 CEST 2019


Didn't add the list...

I guess the closest you get with a pure QByteArray solution is a two-step operation:
auto x = QByteArray::Number(6).rightJustified(10, '0');

-Even

-----Original Message-----
From: Interest [mailto:interest-bounces at qt-project.org] On Behalf Of Kristoffersen, Even (NO14) via Interest
Sent: onsdag 18. september 2019 14:28
To: Jason H <jhihn at gmx.com>; interest at qt-project.org
Subject: Re: [Interest] [External] QByteArray vs QString, arg, why is there no arg()?

Just use the fill() function:  https://doc.qt.io/qt-5/qbytearray.html#fill


-Even

-----Original Message-----
From: Interest [mailto:interest-bounces at qt-project.org] On Behalf Of Jason H
Sent: onsdag 18. september 2019 13:16
To: interest at qt-project.org
Subject: [External] [Interest] QByteArray vs QString, arg, why is there no arg()?

Shiver me timbers! I often find myself using QString::arg() overloads for formatting, but nothing like that exists for when I'm working with just bytes, say for a socket or serial port. So I find myself constructing it as a QString and then .toLocal8bit() ,  which just seems wasteful.

What's the best way to zero-pad a QByteArray?
What I want is QByteArray("%1").arg(6, 10, 10, '0')

I'm guessing they is a good reason it hasn't been added yet?
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list