PDA

View Full Version : Scroll bar jumps to the top after editing value.



kaushal_gaurav
29th April 2009, 12:28
Hi,

I have a Qwidget which is promoted to MyTreeView.
MyTreeView is derived from QTreeView. In the class MyTreeView i have delegates for the rows.. set through the function SetItemDelegateForColumn();
The data in the MyTreeView is populated from MyProxyModel.
Every thing works fine.. data is lengthy and scrollbar is shown for the view.
Now the issue is when i edit any entry in the MyTreeView.. the scrollbar jumps to the begining after pressing enter.

Please help.
Regards,
GK

e8johan
30th April 2009, 10:29
Could it be that you reset the entire model when you have edited the value? You could overcome this by ensuring that your index is visible: http://doc.trolltech.com/4.5/qtreeview.html#scrollTo .

kaushal_gaurav
30th April 2009, 12:12
Hi e8johan,

I have already tried scrollTo(index) function.
I emited the signal from setData() function and in the slot i do scrollTo(index) but the app crashes in scrollTo() function.

What can be the reason or is there any other solution?

Regards,
Gk

e8johan
30th April 2009, 12:18
I'd say that the reason is that the proxy model that you use resets the entire model after editing... try editing without having the proxy model there and see if the behaviour improves. In that case you need to fix the proxy model.