Use of the ARG () method for Qt qstring

Source: Internet
Author: User

The arg () method of the qstring is used to populate the string with the%1,%2 ... for a given parameter, such as

QString m = tr ("%1:%2:%3"). Arg ("n"). Arg ("a"). Arg ("a");    m = "12:60:60:

It also has another overloaded method:

QString qstring::?arg (int a, int fieldwidth = 0, int base = ten, Qchar Fillchar = Qlatin1char (")) const


This method is used to populate the%1,%2 in the string ... for a fixed number, where the first parameter is the number to fill, the second parameter is the minimum width, the second argument is a binary, and the fourth parameter is the character used for padding when the original number is less than the minimum width.


Such as

        QString Text = QString ("%1:%2")                       . Arg (123, 5, Ten, Qchar (' 0 '))                       . Arg (456, 5, Ten, Qchar (' 0 '));    Text = "00123:00456"


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use of the ARG () method for Qt qstring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.