
Originally Posted by
tommy
How do you convert numbers into text for QString.
For example, I want to build a word 2house4 using append(). I know how to make such a string but I want the string to be all text (the numbers should also be treated as text):
test.append(2);
test.append("house");
test.append(4);
QString test;
test.append(2);
test.append("house");
test.append(4);
To copy to clipboard, switch view to plain text mode
This doesn't work:
test.append(2).text();
test.append("house");
test.append(4).text();
QString test;
test.append(2).text();
test.append("house");
test.append(4).text();
To copy to clipboard, switch view to plain text mode
thanks
You can do it like this :
test
= QString ( "%1%2%3" ).
arg ( 2 ).
arg ( "house" ).
arg ( 4 );
QString test;
test = QString ( "%1%2%3" ).arg ( 2 ).arg ( "house" ).arg ( 4 );
To copy to clipboard, switch view to plain text mode
If all three paarams where strings ( up to 10 ), you can use alternative syntax :
test
= QString ( "%1%2%3" ).
arg ( "2",
"house",
"4" );
test = QString ( "%1%2%3" ).arg ( "2", "house", "4" );
To copy to clipboard, switch view to plain text mode
Bookmarks