Problems with QTextEdit and pasting



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



  • 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



  • 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)!



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



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



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



  • I cant see a problem here to cause such!

    Perhaps, your style sheet ?


Log in to reply
 

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