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

Jason H jhihn at gmx.com
Wed Sep 18 13:16:14 CEST 2019

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?

More information about the Interest mailing list