Results 1 to 4 of 4

Thread: How to tell if cell in QTableView is visible ??

  1. #1
    Join Date
    Feb 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to tell if cell in QTableView is visible ??

    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.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to tell if cell in QTableView is visible ??

    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

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to tell if cell in QTableView is visible ??

    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

  4. #4
    Join Date
    Feb 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to tell if cell in QTableView is visible ??

    Quote Originally Posted by aamer4yu View Post
    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.

Similar Threads

  1. how to color a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 13
    Last Post: 9th September 2015, 10:08
  2. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  3. cell selection in QTableView
    By user in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2008, 01:01
  4. How to select a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 6
    Last Post: 6th February 2008, 13:20
  5. Text in QTableView cells not visible
    By juliarg in forum Newbie
    Replies: 2
    Last Post: 22nd March 2007, 15:49

Tags for this Thread

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.