Results 1 to 5 of 5

Thread: QClipboard

  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QClipboard

    Hi,
    I have subclassed a QTextEdit, which presents html. If there is a paste from a different application, plaintext should be inserted
    and if there is a paste from within the application, the normal html should be inserted.

    Maybe you know, how I can notice if there is an intern paste or an extern?

    thank you

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QClipboard

    I'm not sure that i understand you, are you trying to paste html if the copy command was made on your QTextEdit derived widget (or your application) and plain text if the copy was made from a different application?
    A simple answer is to catch copy (Ctrl+C) on your textEdit and make a copy of the string from clipboard and on paste you can compare the pasted string with your copy and decide what you actually do forward... this might not be the best solution - but first explain us what are you trying to do and maybe someone has a better idea.

    //also if i remember correctly (not sure about this so you should consult the documentation) the QClipboard class has a changed signal, so you can be noticed when the user copy something on other application and dump your old copy of the html string.

  3. The following user says thank you to Zlatomir for this useful post:

    Qiieha (19th December 2012)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QClipboard

    Your goal is very strange. Usually it is the copying application that decides on the data format it is preparing and the target application only accepts some formats and rejects others, it doesn't care where the data comes from. Usually I'd suggest to reimplement all the drop related actions to accept both text/html and text/plain. If you really insist on having the functionality you seek then you need to teach your application to prepare the data in a custom mime format (e.g. text/x-mycustomapplicationformat) and tell your application to reject text/html but accept text/plain and text/x-mycustomapplicationformat. Your app needs to treat the latter as HTML.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following 2 users say thank you to wysota for this useful post:

    Qiieha (19th December 2012), Zlatomir (19th December 2012)

  6. #4
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QClipboard

    Thank you guys.
    Your advices helped very much....


    Added after 1 23 minutes:


    Hi,
    ok I followed wysotas advice and reimplementes the drag/drop(copy/paste) methods of QTextEdit....

    In create createMimeDataFromSelection I create a new QMimeData Object and the ownership is transferred to the caller...but who deletes the QMimeData object?

    thanks
    Last edited by Qiieha; 19th December 2012 at 09:33.

  7. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QClipboard

    Quote Originally Posted by Qiieha View Post
    but who deletes the QMimeData object?
    Qt will take care of it when it is no longer needed.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    Qiieha (19th December 2012)

Similar Threads

  1. QClipboard
    By jc in forum Qt Programming
    Replies: 1
    Last Post: 10th January 2012, 16:11
  2. CSV QClipboard and Excell
    By mstegehu in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2011, 07:46
  3. how to copy file to qclipboard?
    By zjf_ha in forum Newbie
    Replies: 1
    Last Post: 13th September 2010, 09:28
  4. From QClipboard to OS FileManager
    By wirasto in forum Qt Programming
    Replies: 0
    Last Post: 28th May 2010, 12:54
  5. QClipboard and Windows
    By GodOfWar in forum Qt Programming
    Replies: 5
    Last Post: 21st July 2008, 09:05

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.