PDA

View Full Version : How to tell if cell in QTableView is visible ??



steviekm3
27th February 2009, 14:19
I have a big QTableView that has scroll bars. Many rows and columns are not visible, meaning you have to scroll to seem them.

Does anybody know how to tell if a cell at a particular row,column must be scrolled to in order to be seen ? Eg it is not visible currently but would be if it was scrolled to.

aamer4yu
27th February 2009, 17:07
What do you intend to do if the item is visible or not ? Usually the view takes care of displaying the items. You need to worry about data in the model.

Also if you need it badly, you can query the visualRect of the item, and see if it is within the viewport rect...am not sure if viewport cordinates are always (0,0) or vary as you scroll, but you can try it

talk2amulya
27th February 2009, 18:20
i think viewport coordinates are always (0,0)..just widget inside is moved as we scroll down or up..and about the problem..visualRect() or maybe directly scrollTo() will work..but until we know what u want, its just a guessing game

steviekm3
27th February 2009, 18:57
What do you intend to do if the item is visible or not ? Usually the view takes care of displaying the items. You need to worry about data in the model.

Also if you need it badly, you can query the visualRect of the item, and see if it is within the viewport rect...am not sure if viewport cordinates are always (0,0) or vary as you scroll, but you can try it

Well some more details. I am working on an App that is stable and is being used in a production system but takes up lots of CPU. The App is basically a table which is a QTableView. The users have typically a few hundred rows. But only about 30 or so rows are visible at a time due to screen size of the monitor. The rest of the rows can be scrolled to.

We have real time data coming in and each time data comes in cells are updated with that new data. What happens now is the data contains a key which allows me to located the cell of the data. Then the cell is updated with the data itself or some calculation on the data ( the calculation itself can take a fair bit of time ). If a cell is not visible we want to perform no calculations at all and not set the cell at all. The data comes in fast enough and refreshes enough from the real time system that if the user scrolls to cells not visible they will fill with the updated data as very shortly new data will come in. Discarding the updates from the real time system therefore is not a problem.

Does this make any sense ? If I am not being clear let me know.