PDA

View Full Version : How to copy QTableWidget to Clipboard



ranna
30th September 2008, 12:05
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

netuno
30th September 2008, 16:47
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