Results 1 to 2 of 2

Thread: Why is QListView::setRootIndex() necessary when working with Dir's?

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Why is QListView::setRootIndex() necessary when working with Dir's?

    I created a post about a week ago and my problem was not resolved. I am pretty sure my problem will be resolved if I could only understand why QListView::setRootIndex() is necessary when working with Dir's. I've used a QListView before and I've never had to use this function but now that I am displaying Dir files on a QListView, I now have to use this function. The problem I have is that I have a QSortFilterProxyModel which I am using to search for certain files in the Dir, but because the view is linked to the underlying model (i.e. QFileSystemModel) through setRootIndex(), my program crashes everytime I try to search for certain files. Is there a way of mapping the root index of the QSortFilterProxyModel to the QListView because that would be my solution to the problem. My code is on my post from last week here

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why is QListView::setRootIndex() necessary when working with Dir's?

    setRootIndex() has nothing to do with QDir, it is needed to select which node if a tree model to consider as the "root" for which to display the list.

    I.e. QListView can only show a list, if you pass a tree model, you can specify which node in the tree is the one you want listed.

    Cheers,
    _

Similar Threads

  1. QSortFilterProxyModel vs setRootIndex()
    By migel in forum Newbie
    Replies: 2
    Last Post: 20th July 2012, 20:43
  2. Replies: 8
    Last Post: 26th May 2011, 16:52
  3. QTreeView & setRootIndex
    By Anonymous in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2010, 06:51
  4. QListView StyleSheet NOT WORKING!
    By QbelcorT in forum Qt Programming
    Replies: 5
    Last Post: 22nd March 2009, 09:38
  5. QTableView row height via delegate and setRootIndex
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 20:06

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.