PDA

View Full Version : Problem pasting text into a QTextEdit



Spockmeat
25th October 2006, 14:47
Currently using Qt 4.2.1

I have a document in word format. If I try to use word 2000 to copy some text and paste it in a QTextEdit box in my application, the text will not paste in properly. Randomly throughout the pasted text there will be missing spaces. The same thing happens if I use open office to open the document and copy/paste text, as well as if I save the document as an html file and use firefox. However, if I open the html file in IE the copy/pasting works fine. Similarly, opening the original document in word 97, or wordpad causes the text to copy/paste correctly. This happens under windows 2000 and Xp. Everything seems to work fine under Linux.

There was also an oddity I found. If I select a portion of text and end right at the last '.' in the paragraph, and copy that and paste it into my QTextEdit box, the font size and such will be the same as in the original document. But if I grab an extra new line in the selection, when I paste the text in, the font will be whatever the default font characteristics are for my QTextEdit box. Similarly, if I have a list of bulleted items, just stopping at the last item and copy/pasting causes the last item to not be bulleted, but rather it appears as bolded and appended to the previous bulleted item. Grabbing an extra new line after the last bulleted item causes the copy/paste to function properly.

I'll attempt to use an older version of Qt to see if this is a new problem, but it'll take a while as my windows test box is very slow (~400MHz).

Has anyone else noticed a problem like this? It seems to me that this is a problem with copy/pasting rich text. My current workaround is to open the document in wordpad.

Spockmeat
26th October 2006, 16:03
Same thing happens in QT 4.1.5. Can anyone verify this happens to them quickly? Simple to reproduce, just open up the rich text example SyntaxHighlighter or create a new dialog, stick on a QTextEidt box and hit preview. Then open up a document in firefox, openoffice, or word 2000 on a win2k or xp box, copy a bunch of text and paste it back in the QT program and see if the text is screwed up.

I searched through the bug reports on Trolltech's site, but didn't find anything similar.

jacek
26th October 2006, 19:46
Same thing happens in QT 4.1.5. Can anyone verify this happens to them quickly? Simple to reproduce, just open up the rich text example SyntaxHighlighter or create a new dialog, stick on a QTextEidt box and hit preview. Then open up a document in firefox, openoffice, or word 2000 on a win2k or xp box, copy a bunch of text and paste it back in the QT program and see if the text is screwed up.
I've tried pasting something from Firefox to a dialog with QTextEdit and everything looked OK (Qt 4.1.5, windows XP).

Spockmeat
26th October 2006, 21:32
I just tried 4.0.1 on this machine and it does the same thing.

Just so you can see what I'm talking about and can try reproducing exactly. I went to wikipedia, and searched for computers. I grabbed the text from the first couple of paragraphs, pasted it into the syntaxhighlighter (just wanted a qtextedit box, same thing happens in any other program for me), and took a screenshot. You can see scattered throughout the image there are spaces missing between some words. This is just so weird, I have no clue at all what could be causing this.

jacek
26th October 2006, 22:00
I have no clue at all what could be causing this.
Maybe there's something wrong with the encoding or fonts?

As you can see in the attachment, it works for me.

Spockmeat
27th October 2006, 16:06
Hum, so it must be something wrong with my version then... just a standard win2000 box, pentiumII based celeron, installed from the executable package.

I'll try recompiling Qt myself to see if that'll fix it. :)

crazY
28th February 2009, 20:04
Excuse my english)

I have some problem with Qt 4.4.3.
I know, that it happens because QMimeData::html(), which is used by QClipboard do not convert line-breaks to spaces, as any browser or rich text editor does.
I temporary use QString::simplified(), but it isn't a solution at all because of unwanted trimmings.

Anyone can help?

crazY
2nd March 2009, 01:45
I have some problem with Qt 4.4.3

I have the same problem

crazY
14th March 2009, 14:36
Solved in Qt 4.5 :rolleyes: