PDA

View Full Version : How to copy from Excel and paste to QTableView



sms
23rd July 2008, 14:01
Hello everyone,

I already manage to copy rows and column data from QTableView to Excel. Using QApplication::clipboard() and QMimeData classes. I use ctrl +c to call the method to copy to clipboard and ctrl +v to paste. This last one is the default shortcut.

But I am stuck now :eek: , I cant find out the way to do it the other way around. I use ctrl +c from excel to copy to clipboard but ctrl +v doesnt do anything to QTableView.
I though it could be a problem related to flags. I set setAcceptDrops(true), then I thought about setDragDropMode(QAbstractItemView::DropOnly) ( I dont want drag enable because i use my own types for the table items and It crashes if I only drag and drop items.

HElP with hints. Can I find and example anywhere?
Thanks in advance :)

fnmblot
23rd July 2008, 15:03
Check out the C++ GUI Programming with Qt4 book. Google has it scanned in here. (http://books.google.com/books?id=tSCR_4LH2KsC&pg=PA101&lpg=PA101&dq=copy+paste&source=web&ots=E511hS4aCk&sig=EYaYF4Er89UKAnKFRZLHYgtTdO4#PPP1,M1) That book pretty much teaches how to create a spreadsheet app.

sms
24th July 2008, 10:00
Thanks fnmblot :)
This hint was very helpful! I found what I was looking for...

georgep
8th November 2008, 23:32
Can you please tell me how do you paste from excel to qt ?

baskar.v
7th February 2009, 00:50
Can you please tell me how do you paste from excel to qt ? ( sample code will help me )

chackal_sjc
7th February 2009, 04:58
You need to see how excel save its selection to the clipboard, then handle it.

If you want Qt -> excel, just use \t for column and \n for line, excel will understand it.