PDA

View Full Version : Invisible information associated with certain row in QTableWidget.



kremuwa
2nd August 2010, 23:40
I'm using QTableWidget to represent data in my peer2mail client - each row stores data of one file. When user performs an action on any file (= row), for example when he pauses it, I need to know which file has been paused. Until now, each file/row had its unique id which was equal to the numer of row in which its data was stored. I've been using currentRow() function to know which file is paused/deleted/resumed. But because I want to let user sort the files by name, size etc. and remove specific file/row from the client, I can't use currentRow() function anymore, because it'll not return correct unique id, since it's no longer equal to the number of the row.
Then what I want to do, is to assign an unique id to the file/row on its addition to the table so that if I select the row and click "pause" button the file/row id will be returned. I was wondering how to do it, I tried to make an addtional, invisible column in which each row would have its id but I don't know how to turn off the visibility.

Lykurg
3rd August 2010, 06:59
I tried to make an addtional, invisible column in which each row would have its id but I don't know how to turn off the visibility.

That's the right way. See QTableView::hideColumn(). Or you also can add to every first item of your table a cutom user data and read that out. But a hidden column is the best.