Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit, how to insert multiple lines?
Forum Update on Monday, May 27th 2025

QTextEdit, how to insert multiple lines?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 3.0k Views
  • 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have a QTextEdit in a form, how do I display text on separate lines? From am SQL database I have an entry that is an house address, each line of the address is delimited with a carriage return (13).

    To add this to the control I use the text function, but the lines are just displayed as a single with no carriage return.

    Is there a standard way to achieve this? I've tried googling QTextEdit and Multiline entry but didn't find anything specific to my issue.

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I have a QTextEdit in a form, how do I display text on separate lines? From am SQL database I have an entry that is an house address, each line of the address is delimited with a carriage return (13).

      To add this to the control I use the text function, but the lines are just displayed as a single with no carriage return.

      Is there a standard way to achieve this? I've tried googling QTextEdit and Multiline entry but didn't find anything specific to my issue.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SPlatten Are you on Windows? If so try to replace "\n" with "\r\n".

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 1 Reply Last reply
      0
      • jsulmJ jsulm

        @SPlatten Are you on Windows? If so try to replace "\n" with "\r\n".

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @jsulm, my development system is an iMAC.

        Kind Regards,
        Sy

        jsulmJ 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @jsulm, my development system is an iMAC.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @SPlatten Is there a difference if you use setPlainText?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          SPlattenS 1 Reply Last reply
          0
          • jsulmJ jsulm

            @SPlatten Is there a difference if you use setPlainText?

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @jsulm , I've just inserted:

            strText.replace("\n", "\r\n");
            

            Before setting the text, that didn't make any difference, replaced setText call with setPlainText. No difference either that was also with the replace statement still in.

            Kind Regards,
            Sy

            jsulmJ 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @jsulm , I've just inserted:

              strText.replace("\n", "\r\n");
              

              Before setting the text, that didn't make any difference, replaced setText call with setPlainText. No difference either that was also with the replace statement still in.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @SPlatten I can't test on Mac, but on Windows setting text with \n using setText() works correctly.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              SPlattenS 1 Reply Last reply
              0
              • jsulmJ jsulm

                @SPlatten I can't test on Mac, but on Windows setting text with \n using setText() works correctly.

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by SPlatten
                #7

                @jsulm ,Sorry, it does work, I'm having a bad day....I looked at the debugger again and I was mistaken.

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  ollarch
                  wrote on last edited by
                  #8

                  Keep calm and take some time to look at debugger. Again, spending more time writing here than inspecting the debugger.

                  1 Reply Last reply
                  0
                  • Ketan__Patel__0011K Offline
                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011
                    wrote on last edited by
                    #9

                    Use Append Function for It

                    QTextEdit::append("Your String");

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved