New line (\n) doesn't work



  • Hi,
    I try to use the code below in a QMessageBox.

    QString submit_warning;
     submit_warning = submit_warning + "<b><font size='16' color='red'>*Please add a picture of the Friend!\n</b></font>";
    

    The text is displayed nicely, but the new line character is not working. It prints the next warning in the same line.
    Please tell me what I did incorrectly.
    Thank you.



  • Going by memory (so I might be wrong)....

    Short version: use a "<br>" instead.

    Long version: QMessageBox::textFormat defaults to Qt::AutoText, which attempts to detect if you're using Qt::PlainText or Qt::RichText. I believe that "\n" works for PlaintText, while "<br>" works for RichText. And I'm guessing, your existing HTML markup (such as "<b>") will cause the detection to choose RichText.

    Cheers.



  • Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.