Results 1 to 4 of 4

Thread: by default how to make QTreeView in extended state

  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question by default how to make QTreeView in extended state

    i have a QTreeView ,and its pointing to some location, so i can see all the folders which are in that location . By default all the sub folders are in collapse mode how to make it to EXTENDED mode

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

    Default Re: by default how to make QTreeView in extended state

    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. #3
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: by default how to make QTreeView in extended state

    QFileSystemModel *model = new QFileSystemModel;
    model->setRootPath(QDir::currentPath());
    QString strPath ="/home/Desktop/PATHS";
    ui->treeView->setItemsExpandable(true);
    ui->treeView->setModel(model);
    ui->treeView->setRootIndex(model->index(strPath));
    ui->treeView->expandAll();

    i tried these too but it din't work.

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

    Default Re: by default how to make QTreeView in extended state

    Since QFileSystemModel works in an asynchronous fashion, you need to call expandAll() only after QFileSystemModel::directoryLoaded() signal is emitted for the directory you need. Alternatively you can connect to that signal and upon receiving the path that has been completed, convert it to QModelIndex using QFileSystemModel::index() and then call QTreeView::expand() on the calculated index. Then you'll be expanding directories as they are being scanned.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 11th July 2011, 12:50
  2. Replies: 0
    Last Post: 19th December 2010, 16:03
  3. Replies: 1
    Last Post: 2nd December 2010, 10:07
  4. Replies: 0
    Last Post: 1st November 2010, 08:22
  5. QTreeView default drag action
    By onamatic in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 07:37

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.