Results 1 to 3 of 3

Thread: How to add folder contents to qtreeview

  1. #1
    Join Date
    Feb 2014
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11

    Question How to add folder contents to qtreeview

    hello I have a question ... how can I pass data from a folder to a treeview ...
    all this via a button.
    ie I click on the button and I select the items I need window Habré and want those items are displayed in a treeview
    thanks in advance ..
    God bless you

  2. #2
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to add folder contents to qtreeview

    Here is a good example of TreeView and here is a tutorial for Model/View

    After you know how to create a treeview with folders/files as content, then you can do the following:
    Add a button, make a slot where you call the tree view widget whenever the button is clicked.

    I am sorry if you are looking for already made code.

    Good luck.

  3. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to add folder contents to qtreeview

    Consider whether you need the QTreeView (a model, abstract and general) or whether you need the QTreeWidget (a ready-to-use tree structure). If you need a QTreeWidget, then:

    Adding non-top level item is made at the QTreeWidgetItem level. You need pointers to the parent node and the added item, then do parentNode->AddChild(item) for one item or create QList<QTreeWidgetItem *> from more items added simultaneously and then parentNote->AddChildren(list). Note that the pointers to the added item(s) get owned by the tree and that they need to be created by new. The list itself can be deleted after adding.

    Adding top level items is made at QTreeWidget level. Do tree->addTopLevelItem(item) for one item or tree->AddTopLevelItems(list) for a list of items. You can also get the pointer to the invisible root item: root = invisibleRootItem() and add child(ren) as above: root->addChild(item) or root->addChildren(list).

Similar Threads

  1. Replies: 3
    Last Post: 11th December 2012, 16:32
  2. Replies: 0
    Last Post: 13th October 2010, 04:27
  3. My qt folder is so big!!!Help
    By chinaeli in forum Newbie
    Replies: 3
    Last Post: 22nd January 2010, 10:22
  4. Replies: 1
    Last Post: 19th January 2010, 21:35
  5. Replies: 8
    Last Post: 5th August 2008, 12: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.