Some function descriptions about qstring

Source: Internet
Author: User

1 Qstring::arg ()//replace string with string variable parameter • Minimum value

Example 1:

QString str;

str = QString ("%1 is born in%2."). Arg ("John"). Arg (1992);//srt = "John is born in 1992.";

Where%1 was substituted for "John"%2 was replaced by "1992"

Example 2:

QString i = "ITest"; //Current file ' s number

QString total = "Totaltest"; // number of files to process

QString fileName = "Filenametest"; //Current file ' s name

QString status = QString ("processing file%1 of% 2:%3"). Arg (i). Arg (total). Arg (fileName);

The result is: "Processing file iTest of Totaltest:filenametest"

2

QString str = "   123  4  ";
str = str.trimmed ();//Remove the white space character of the 2 end of the string as the result of "123 4"
    str = str.simplified ();//Remove the white space character of the 2 end of the string using a single whitespace character "" Instead of the white space characters that appear in the string result is "123 4"



    QString str = "1234";
    QString str1 = "Abxd";
    str = Str.insert (1, ' C ');//Insert another string or character at a specific location in the original string
str = str.insert (1, "QQ");
    Qdebug () <<str;//"1c234"

4 prepend ();//Insert another string at the beginning of the original string

5
QString str = "1234";
str = str.replace ("Qwer");//from the first position of the string, use the string in parentheses instead of the original number of characters
Qdebug () <<str;//results for "1qwer4"

Some function descriptions about 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.