Results 1 to 3 of 3

Thread: QDirModel

  1. #1
    Join Date
    Jan 2006
    Location
    Ukraine, L'viv
    Posts
    57
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDirModel

    I have two classes, one based on QTreeView (dirsView) and second on QListView (filesView). dirView has QDirModel with QDir::Drives | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks set and filesView with QDir::Files.
    When directory is pressed dirsView emits directoryChanged(dirsModel->filePath(index)) and filesView connects this signal to slot with next code:
    Qt Code:
    1. filesView->setRootIndex(filesModel->index(path));
    To copy to clipboard, switch view to plain text mode 
    Now, when I press on directory in dirsView, filesView shows files, all is OK. Then I press on subdirectory and again on previous directory, filesView shows files and subdirectory. So it shows every subdirectory that was pressed before. To change this I've inserted into slot next code:
    Qt Code:
    1. filesModel->setFilter(QDir::Files);
    2. filesView->setRootIndex(filesModel->index(path));
    To copy to clipboard, switch view to plain text mode 
    But isn't it hack? Is it possible to do it in another way?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel

    A screen shot and some more code would help in providing an answer.

    Regards

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine, L'viv
    Posts
    57
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel

    You can look at example in attachment.
    Attached Files Attached Files

Similar Threads

  1. QDirModel - show directory ".."?
    By jamd in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2009, 19:51
  2. Replies: 2
    Last Post: 12th April 2007, 11:11
  3. QTreeView and QDirModel Header Sort Question
    By jimroos in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2007, 08:04
  4. QDirModel, Model/View, extend the file onfo
    By VlJE in forum Qt Programming
    Replies: 10
    Last Post: 11th December 2006, 10:56
  5. QDirModel and a QTreeView.
    By jamd in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 09:41

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.