For example: For example, 1, I want to convert it to "001".
There are two ways:
method one:
int i=1; QString b=QString("%1").arg(i, 3, 10, QChar('0'));
Among them, 3 means that 3 digits need to be reserved, 10 is decimal, and it is followed by 0.
Method Two:
int cmd=1; QString str=QString::number(cmd).sprintf("%03d",cmd);