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 Updated to NodeBB v4.3 + New Features

QTextEdit, how to insert multiple lines?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 3.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 24 Feb 2021, 11:58 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

    J 1 Reply Last reply 24 Feb 2021, 12:02
    0
    • S SPlatten
      24 Feb 2021, 11:58

      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.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 24 Feb 2021, 12:02 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

      S 1 Reply Last reply 24 Feb 2021, 12:02
      0
      • J jsulm
        24 Feb 2021, 12:02

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

        S Offline
        S Offline
        SPlatten
        wrote on 24 Feb 2021, 12:02 last edited by
        #3

        @jsulm, my development system is an iMAC.

        Kind Regards,
        Sy

        J 1 Reply Last reply 24 Feb 2021, 12:03
        0
        • S SPlatten
          24 Feb 2021, 12:02

          @jsulm, my development system is an iMAC.

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 24 Feb 2021, 12:03 last edited by
          #4

          @SPlatten Is there a difference if you use setPlainText?

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

          S 1 Reply Last reply 24 Feb 2021, 12:06
          0
          • J jsulm
            24 Feb 2021, 12:03

            @SPlatten Is there a difference if you use setPlainText?

            S Offline
            S Offline
            SPlatten
            wrote on 24 Feb 2021, 12:06 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

            J 1 Reply Last reply 24 Feb 2021, 12:09
            0
            • S SPlatten
              24 Feb 2021, 12:06

              @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.

              J Online
              J Online
              jsulm
              Lifetime Qt Champion
              wrote on 24 Feb 2021, 12:09 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

              S 1 Reply Last reply 24 Feb 2021, 12:11
              0
              • J jsulm
                24 Feb 2021, 12:09

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

                S Offline
                S Offline
                SPlatten
                wrote on 24 Feb 2021, 12:11 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 24 Feb 2021, 12:41 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
                  • K Offline
                    K Offline
                    Ketan__Patel__0011
                    wrote on 24 Feb 2021, 12:44 last edited by
                    #9

                    Use Append Function for It

                    QTextEdit::append("Your String");

                    1 Reply Last reply
                    0

                    3/9

                    24 Feb 2021, 12:02

                    topic:navigator.unread, 6
                    • Login

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