Results 1 to 2 of 2

Thread: How to copy QTableWidget to Clipboard

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy How to copy QTableWidget to Clipboard

    I want to copy the QTableWidget to Clipboard as a whole. Please let me know the possible way.

    i Have a QTableWidget with n rows and n colums. I want to paste the entire TableWidget (without changing any format) to Clipboard. Is there any way to do this?

    Thanks.
    Ranna
    Last edited by ranna; 30th September 2008 at 15:23.

  2. #2
    Join Date
    Aug 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to copy QTableWidget to Clipboard

    Hey,

    I think one way to do this would be treat the copy/cut/paste shortcuts into calling a function, which would provide the mimedata to the clipboard on the case of cut/copy, or read it in the case of paste.
    I believe the idea is to read the table contents, and create a format (XML or JSON as an option) to store the table data on, and then call the QClipboard setMimeData function.
    The paste would have to be able to read this format and populate a table widget.
    Take a look at functions retrieveData, data, and hasFormat from QMineData.
    Maybe just using html could be easier than creating a new format. You would just need to generate the html table code for cut/copy and parse it for the paste.
    I hope this helps.

    Luiz

Similar Threads

  1. Copy row(s) from QTableWidget
    By allensr in forum Qt Programming
    Replies: 10
    Last Post: 1st February 2017, 09:59
  2. Replies: 1
    Last Post: 27th November 2014, 10:11

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.