[PyQt] QTreeView scrolling on selection

Yuya Nishihara yuya at tcha.org
Mon Nov 22 16:48:25 GMT 2010


Steve Borho wrote:
> Hello,
> 
> We use a QTreeView to present a list of files in our commit tool.  The
> view has 4 columns, the largest of which is the file name.  We don't
> really like Qt's behavior of scrolling horizontally when an item is
> selected, most of the time the user wants column 0 visible since it
> has the file selection check boxes.
> 
> We have a hack in place which disables this horizontal scrolling:
> 
> http://bitbucket.org/tortoisehg/thg/changeset/d3c50e52949b
> 
> But I was curious if anyone knew of a cleaner way to accomplish this.  Cheers.

Hi, I made this change yesterday, and it was described at Qt FAQ:
http://developer.qt.nokia.com/faq/answer/how_can_i_disable_autoscroll_when_selecting_a_partially_displayed_column_in

But today I found much simpler, but *undocumented* behavior:

    setAutoScroll(False)

Though the document says "This property only works if the viewport accepts
drops.", it just works. :)

http://doc.qt.nokia.com/4.6/qabstractitemview.html#autoScroll-prop

Does anyone know this is
- an expected behavior and documentation bug
- or unexpected behavior ?

Thanks,
Yuya


More information about the PyQt mailing list