简体   繁体   中英

QString format %1 but multiple arguments

I stumbled upon this line of code in a project I am working on:

QString("%1").arg(2176782335, 6, 36, QChar('0')).toLatin1()

Why are there even multiple arguments for just %1 ? Shouldn't this only accept the first parameter in arg() ?

It looks like this overload of QString::arg . Arguments are:

  • number to be displayed (integer in this case)
  • minimum amount of space for the rendered number
  • base (hex/dec/oct/whatever) - in your example it is quite unusual system with base 36 which uses all digits and all letters of Latin alphabet
  • filler character

If you want multiple placeholders in your string, just call arg multiple times, like shown in the docs.

Also read about number formats .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM