[Solved] Automatically scroll to edited cell of QTableWidget?
-
Hi,
I am using a QTableWidget in Main Window class. There are more cells than the screen can show, hence scroll bars are created automatically. Now I am changing certain cells text by code. This happens successfully, but the scroll bars don't change automatically to show the edited cell. So if the cell is not in the visible region the user does not know which cell is getting changed. However when I manually scroll I find that the cell is selected automatically.
So my question is what is the best way to update position of scroll bars, so that the cell that is selected may be visible to the user?
Thanks! -
Hi,
What about "scrollTo":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#scrollTo ?
-
Hi SGalst,
Thanks for your answer.
I am not a pro in C++ nor Qt.
So I am finding it a bit difficult how to implement the said function.
Can you please show by code how to use this for a QTableWidget?
Thanks again :) -
You don't have to implement it, just use it.
Since you are modifying a known item, you can get it's index (you might already be using it) and call scrollTo with that index as a parameter
-
Oh yeah!
I used scrollToItem() as that was much easier in my case.
Thanks for your help :)