+ Reply to Thread
Results 1 to 2 of 2

Thread: Qtreeview : To get File name and path from Tree View

  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Qtreeview : To get File name and path from Tree View

    Hi ,

    I am using the below code to show a particular path in tree view. Now when i click a file or select or focused file , i need to get the file path location and file info. How do i get it? Help me

    Qt Code:
    1. QDirModel model;
    2. QTreeView tree;
    3. tree.setModel(&model);
    4.  
    5. // Demonstrating look and feel features
    6. tree.setAnimated(true);
    7. tree.setIndentation(20);
    8. tree.setSortingEnabled(true);
    9.  
    10. tree.setAllColumnsShowFocus(false);
    11.  
    12.  
    13. QString directory = "/mnt";
    14. tree.setRootIndex(model.index(directory));
    15.  
    16. tree.setWindowTitle(QObject::tr("Dir View"));
    17. tree.resize(320, 240);
    18. tree.show();
    19.  
    20. tree.hideColumn(1);
    21. tree.hideColumn(2);
    22. tree.hideColumn(3);
    23.  
    24. return app.exec();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,368
    Thanks
    19
    Thanked 992 Times in 903 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qtreeview : To get File name and path from Tree View

    See QDirModel::fileInfo() or QDirModel::filePath() in conjunction with the current selected index or any other index. E.g. QAbstractItemView::activated().

+ Reply to Thread

Similar Threads

  1. Tree View
    By bismitapadhy in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2009, 07:31
  2. C++ Tree View operation
    By zeeb100 in forum Qt Programming
    Replies: 9
    Last Post: 18th February 2009, 18:09
  3. Replies: 12
    Last Post: 7th February 2007, 14:30
  4. qtreeview -file path
    By onder in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 10:40
  5. tree view!!
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 9th May 2006, 15:09

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