PDA

View Full Version : QTreeView scrollTo when GUI is not done with painting all widgets



Gh0str1d3r
19th July 2010, 15:42
Hi,

I am using a QTreeView and want to jump to the last selected item at startup. This, unfortunately, does not work as I want it to, because the item is selected before the widget is painted and therefore, during the filling and reordering of the related QFileSystemModel, the selection moves out of the visible area. Any suggestions how to achieve the wanted behavior (i.e. the selection being in the view after the GUI is fully shown)?

Thanks for help.

Gh0str1d3r
29th July 2010, 13:55
Does no one have any experience with this? I would have guessed it is quite common to initialize a FileSystemBrowser with the last used structure, isn't it?

winkle99
27th August 2010, 23:48
Hi,

Was looking around for a solution to this problem myself. (Wouldn't it be simpler just to have a flag you can set on the List or table view? ) Anyway, I googled and found a mention over on one of the Qt lists that pointed out that the problem is that the widget has to be visible before scrollTo works. My work around was to add a showEvent method and make the call there after calling, in my case, QDialog::showEvent. Seems to be working for now.

Gh0str1d3r
29th August 2010, 15:18
thanks a lot, it works! (only I had to use PaintEvent because ShowEvent is delivered before the widget is shown)