If you mean - how to know when view was scrolled and what's now visible then here's how:
connect( TableViewObject->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateTable(int)));
...
void updateTable( int val )
{
int visibleRowsCount = TableViewObject->rowCount() - TableViewObject->verticalScrollBar()->maximum();
visibleRowsCount += 1; // extra row in case next row it's partially visible
int indexOfFirstVisibleRow = val;
int indexOfLastVisibleRow = indexOfFirstVisibleRow + visibleRowsCount;
// for each of visible rows call GetPrice() and set new value on the corresponding item
}
connect( TableViewObject->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateTable(int)));
...
void updateTable( int val )
{
int visibleRowsCount = TableViewObject->rowCount() - TableViewObject->verticalScrollBar()->maximum();
visibleRowsCount += 1; // extra row in case next row it's partially visible
int indexOfFirstVisibleRow = val;
int indexOfLastVisibleRow = indexOfFirstVisibleRow + visibleRowsCount;
// for each of visible rows call GetPrice() and set new value on the corresponding item
}
To copy to clipboard, switch view to plain text mode
that's 'on a knee' solution but it should get you where you want.
You mean emitting a data changed signal every 60 seconds will not be hard on the view if it is currently showing only 30-40 items?
It won't be hard if the getPrice() is fast. if it's not then use separate thread to do that and it will still be nice and easy.
Same for scrolling, if getPrice() is slow, stick it into separate thread and update the field when thread finishes. I guess you'll know if it's too slow when you try it.
Also remember to call the updateTable() method from resizeEvent() as well.
Bookmarks