How to add newline to a QString?
I have an error message dialog where I need to pass in a QString.
I want to break up the string into multiple lines. If I add "\n" it didn't work, it's simply ignored.
How can I break up the long string into several lines? TIA for your help.
Well, \n should work, they should patch Qt on this one afaik ;)
But, as far as I remember, </br> could do the trick, as the contents in a QMessageBox is rendered as HTML like string.
Yes , "\n" works with QString , you can try the following code
@ QMessageBox::critical(this,"error","This \n is \n an \n error \n string !!!!!");@
that shows an error dialog like :
\n works when rendered as plain text, <br> works when rendered as html (textFormat: Text.StyledText)
\n is ignored when rendered as html, <br> is rendered as those 4 characters when rendered as plain text