Results 1 to 4 of 4

Thread: Treeview/treewidget to hold list of websites

  1. #1
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Treeview/treewidget to hold list of websites

    Hi,

    Can someone please give me a starting point on how to create a treeview which is kinda like IIS Manager

    Capture.PNG

    So the main items are the list of websites, and every item has directory structures (from file system) under every website's root documents .

    I am totally lost at the model/view/delegate concept.

    I will be watching this thread for any reply since i have nowhere to ask this question.

    Thanks.

  2. #2
    Join Date
    Dec 2011
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Treeview/treewidget to hold list of websites

    There's two ways of doing this in Qt. One is using an "item-based" approach where each folder/subfolder is its own object and you're responsible for creating them.

    Check out QTreeViewWidget ( http://qt-project.org/doc/qt-4.8/qtreeview.html ) to see how you could do it this way.

    The second way is a bit more odd. The basic idea is you implement functions saying "hey, how many items do it have" (row count) and "What are they called?" (data) given the parent node (i.e. folder) in the tree. Once you have that information, it will only be requested when when it's needed (i.e. when you open up a folder, it'll look up what stuff's underneath it and create the items automagically). This is more the MVC approach and you'd QAbstractItemModel and re-implement all the virtual functions that have no default implementation in order for this to work. The good news is that once you have the model, all you need to do is create a QTreeView and hand it the model and you're done. In practice, I generally find this approach better and simpler, but less accessible to newer Qt users. ( http://qt-project.org/doc/qt-4.8/QAb...ItemModel.html )

    Hope this helps Oh and don't worry about delegates. Really, the only thing you need to understand for your example is how your model works. You shouldn't need anything else custom to do this.

  3. The following user says thank you to Agnostic Pope for this useful post:

    doniking (17th May 2012)

  4. #3
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Treeview/treewidget to hold list of websites

    @Agnostic Pope :
    How do I save the values (root dir, listen ip, port, etc) on each website items ?
    Do i still need to use QDirModel for the dir structures below each website items?

    Thank you!
    Last edited by doniking; 9th May 2012 at 18:10.

  5. #4
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Treeview/treewidget to hold list of websites

    i think i will get the root dir , ip, port in real time from the config files.

    Another question, how do I add the QFileSystemModel as the child of each items?

Similar Threads

  1. difference between TreeWidget and TreeView
    By gauravg in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2012, 13:47
  2. Replies: 2
    Last Post: 18th May 2010, 23:44
  3. QWebView not compatible with many websites?
    By aRestless in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2010, 14:02
  4. Can QVector hold objects?
    By N3wb in forum Newbie
    Replies: 6
    Last Post: 14th April 2010, 21:29
  5. QTextEdit does not hold Object Id behind
    By validator in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2008, 01:25

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.