PDA

View Full Version : How to deal with very long QString?



jiapei100
7th February 2013, 04:39
Hi, all:

I'm trying to write a single about() function, with only a QMessageBox as follows:



QMessageBox::information(this,
"My System",
"line 111111111111111111111111111111 \n"
"line 222222222222222222 \n"
"line 33333333333333333333333333333333333" );


However, I seriously don't like the above code style because I need to do \n at the end of every line, which is so inconvenient. I prefer all the info in the 3rd parameter in the above code can be summarized into a single quote instead of 3 quote, and better without \n . Can anybody help please?



Best Regards
Pei

ChrisW67
7th February 2013, 06:37
Help with what? If you want to type it all as a single string without breaks then go right ahead.

Santosh Reddy
7th February 2013, 07:14
You may create a list a QStringList, and merge then with "\n" while setting it on to diplay widget.

wysota
7th February 2013, 11:02
You may create a list a QStringList, and merge then with "\n" while setting it on to diplay widget.

This will still require many strings :-) But as was already said one can put everything in one strong as well. Strings in C/C++ can span across lines.

Santosh Reddy
7th February 2013, 11:13
This will still require many strings :-) But as was already said one can put everything in one strong as well. Strings in C/C++ can span across lines.
As I usderstand OP, they require to speficy multi-line (with line breaks), but does not want to type string with "\n" at the end. C/C++ will just concatinate the strings (will not insert \n).