Results 1 to 3 of 3

Thread: use QTreeView

  1. #1
    Join Date
    Jan 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy use QTreeView

    Dear,
    I want make treeview like explorer.
    I use this script :

    Qt Code:
    1. QDirModel *model=new QDirModel;
    2. treeView->setModel(model);
    3. treeView->setRootIndex(model->index(QDir::currentPath()));
    To copy to clipboard, switch view to plain text mode 

    this script show all file and folder in currentpath.
    my question are :
    1. how to make treeView show all file not file and folder.
    2. when i click file in treeview, i want statusbar show path and filename. I have path, but how to know name of file in current index.
    3. i want to make treeview can rename and delete file. how to solve this program.

    thank you. please help me.

    regardly

    toto
    Last edited by jpn; 30th January 2008 at 08:24. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: use QTreeView

    Quote Originally Posted by totosugito View Post
    1. how to make treeView show all file not file and folder.
    Take a look at QDirModel constructor docs. Especially notice the
    QDir::Filters parameter.

    Quote Originally Posted by totosugito View Post
    2. when i click file in treeview, i want statusbar show path and filename. I have path, but how to know name of file in current index.
    See QAbstractItemView::clicked() or QAbstractItemModel::data(). The former will get emitted whenever an item is clicked. By subclassing QDirModel and reimplementing the latter you could return data for Qt::StatusTipRole which would be automatically shown (presumably whenever an item is hovered, though).

    Quote Originally Posted by totosugito View Post
    3. i want to make treeview can rename and delete file. how to solve this program.
    See QDirModel::readOnly.

    PS. Have you noticed [WIKI]Extended Dir View example[/WIKI]?
    J-P Nurmi

  3. #3
    Join Date
    Jan 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: use QTreeView

    thank for your answer
    my problem is solved with Extended Dir View example

    thank you

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  3. QTreeView: Holding a line on screen
    By gri in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 11:42
  4. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

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.