Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems with QTextEdit and pasting
Qt 6.11 is out! See what's new in the release blog

Problems with QTextEdit and pasting

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello there,

    When I paste text into a QTextEdit widget, each line overlaps the line before it and the cursor goes back to the beginning.

    Is there any way to prevent this from happening?

    I'm using Qt 5.1.1 on a Mac OS X 10.8.5.

    Thanks in advance.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      I am using 5.0 and Not finding issue like this.

      How ever you can manually set the cursor position like "this":http://qt-project.org/doc/qt-5.0/qtwidgets/qlineedit.html#cursorPosition-prop


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks for the answer, Rahul.

        I have actually been able to narrow down the issue to texts copied from Google Drive's documents. The cursor is not going back to the beginning as I first stated, it actually stays where the last line ends.

        I am attaching a picture so you can try to reproduce the problem.
        What I did was type some text, copy the lines and then paste onto the QTextEdit widget.

        This is probably due to the way text is formatted in Google Drive. I don't know if this is restricted to the last version of the SDK or to the OS, though.

        Thanks again.

        !http://s11.postimg.org/dm5qecclf/Captura_de_Tela_2013_10_25_s_03_08_53.png(QTextEdit problem)!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Code_ReaQtor
          wrote on last edited by
          #4

          Have you tried pasting the same text in another text editor, like Notepad++? What would be the output then?

          Please visit my open-source projects at https://github.com/Code-ReaQtor.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Yes, the text is pasted correctly in TextEditor and TextWrangler. It's also pasted correctly in Qt Creator (Edit tab).

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Well, I guess it's a problem with the HTML parser.
              I was able to get the HTML of that sample text, and setting it directly into the QTextEdit results in the same output.

              Here's the HTML:

              @Version:0.9
              StartHTML:0000000105
              EndHTML:0000001264
              StartFragment:0000000141
              EndFragment:0000001228
              <html>
              <body>
              <!--StartFragment--><b id="docs-internal-guid-4c557332-f0af-00b8-4bd5-1b982ea612b4"><p dir="ltr" ><span >This is a sample text, and this line will be longer to illustrate the issue.</span></p><p dir="ltr" ><span >This will be a little bit shorter than the last one.</span></p><span >This will be the shortest one.</span></b><!--EndFragment-->
              </body>
              </html>@

              Can you spot anything that might have caused this behaviour?
              It's also happening on Windows with Qt 5.1.1.

              Thanks again.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rahul Das
                wrote on last edited by
                #7

                I cant see a problem here to cause such!

                Perhaps, your style sheet ?


                Declaration of (Platform) independence.

                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
                • Unsolved