Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved New line (\n) doesn't work

    General and Desktop
    qstring
    3
    4
    7751
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gabor53 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • Paul Colby
        Paul Colby last edited by

        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.

        K 1 Reply Last reply Reply Quote 6
        • G
          gabor53 last edited by

          Thank you.

          1 Reply Last reply Reply Quote 0
          • K
            Kophyogyi @Paul Colby last edited by

            @Paul-Colby thank you

            1 Reply Last reply Reply Quote 0
            • First post
              Last post