Results 1 to 2 of 2

Thread: QTreeView autoresize and autoexpand

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QTreeView autoresize and autoexpand

    Hello,

    In a program that I am making, there is a qtreeview used to show a directory tree, I have a few questions about the widget.

    1) Can I make the tree automatically expand to show a specific path (eg where the file currently in use is)?

    2) When more folders are opened in the view, the column does not expand to accommodate them (and no scroll bar appears), so the contents of folders lower in the tree are not visible unless you manually resize the column width. Is there anyway to make the column 'auto-resize' to accommodate more items?

    Thanks in advance.

    Scrasun
    Last edited by scrasun; 26th September 2009 at 16:05. Reason: spelling error

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView autoresize and autoexpand

    Quote Originally Posted by scrasun View Post
    1) Can I make the tree automatically expand to show a specific path (eg where the file currently in use is)?
    void expandToIndex(QTreeView *tv, QModelIndex index){
    while(index.isValid()){
    tv->expand(index);
    index = index.parent();
    }
    }[/code]

    2) When more folders are opened in the view, the column does not expand to accommodate them (and no scroll bar appears), so the contents of folders lower in the tree are not visible unless you manually resize the column width. Is there anyway to make the column 'auto-resize' to accommodate more items?
    I'm not sure I understand the question but maybe QTreeView::resizeColumnToContents() helps you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    scrasun (26th September 2009)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.