Results 1 to 9 of 9

Thread: Problem pasting text into a QTextEdit

  1. #1
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem pasting text into a QTextEdit

    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.

  2. #2
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem pasting text into a QTextEdit

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem pasting text into a QTextEdit

    Quote Originally Posted by Spockmeat View Post
    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).

  4. #4
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem pasting text into a QTextEdit

    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.
    Attached Images Attached Images

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem pasting text into a QTextEdit

    Quote Originally Posted by Spockmeat View Post
    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.
    Attached Images Attached Images

  6. #6
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem pasting text into a QTextEdit

    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.

  7. #7
    Join Date
    Feb 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem pasting text into a QTextEdit

    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?

  8. #8
    Join Date
    Feb 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem pasting text into a QTextEdit

    Quote Originally Posted by crazY View Post
    I have some problem with Qt 4.4.3
    I have the same problem

  9. #9
    Join Date
    Feb 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem pasting text into a QTextEdit

    Solved in Qt 4.5

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. How to get text of last line only in QTextEdit?
    By rajesh in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2006, 14:37
  3. setting cursor problem in QTextEdit
    By jyoti kumar in forum Qt Programming
    Replies: 3
    Last Post: 19th May 2006, 09:17
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 07:03
  5. Problem with inserting text into QTextEdit
    By xorrr in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2006, 12:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.