Results 1 to 4 of 4

Thread: custom file tree

  1. #1
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Post custom file tree

    Hello.

    I want to do a File Tree (like QTreeView does) but i want it to be custom. First it dont have any file, but when a file or a dir drops on it i want it to be added to root. Also, if the user want to delete one file from one dir that he added, he must be able to (oc without deleting the original file) and keeping the rest of files.

    Example:
    initialy:
    Qt Code:
    1. <root>
    To copy to clipboard, switch view to plain text mode 
    //add directory "test" which contains file1, file2 and dir1 (which also contains file3)
    Qt Code:
    1. <root>
    2. - test
    3. file1
    4. file2
    5. - dir1
    6. file3
    To copy to clipboard, switch view to plain text mode 
    //add file file4
    Qt Code:
    1. <root>
    2. - test
    3. file1
    4. file2
    5. - dir1
    6. file3
    7. file4
    To copy to clipboard, switch view to plain text mode 
    //delete file1
    Qt Code:
    1. <root>
    2. - test
    3. file2
    4. - dir1
    5. file3
    6. file4
    To copy to clipboard, switch view to plain text mode 
    //delete dir1
    Qt Code:
    1. <root>
    2. - test
    3. file2
    4. file4
    To copy to clipboard, switch view to plain text mode 


    If i use QTreeView Widget i must rewrite ModelIndex to make it custom?
    Or any other ideas how to do it?

    Thank you!

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: custom file tree

    Just create a normal model. When you want to add or remove items, emit the appropriate signals and all views will automatically update.

  3. #3
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: custom file tree

    Well, can you give me more informations? The delete action isnt on the physical address, it's just on my program, so i dont really understand how to do that...

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: custom file tree

    beginRemoveRows(...)
    ... remove rows from your data store ...
    endRemoveRows()

Similar Threads

  1. Custom tree view with checkbox and icon - Plz help
    By ttvo in forum Qt Programming
    Replies: 9
    Last Post: 4th July 2019, 12:51
  2. Qtreeview : To get File name and path from Tree View
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2010, 13:14
  3. Custom tree view suggestions
    By jtourville in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2009, 02:23
  4. Custom Tree paint per row
    By Kal in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2008, 00:19
  5. Display a file from Directory tree to show in QTextEdit
    By vvdounai in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 13:43

Tags for this Thread

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.