Results 1 to 5 of 5

Thread: Should I use QTreeView or QTableView?

  1. #1
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Should I use QTreeView or QTableView?

    Hi all,

    I have an application which is written in C# and uses the Control called ListView. Please refer to the attacheded picture to see what I am talking about.

    Now I need to implement the same behaviour in Qt code, and I am trying to find the best implementation solution.

    Here comes my following questions:
    1. Should I use the Model/View framework (I haven't used this and I would take me a while to implement it, but maybe it would worth it)?
    2. Should I use the QTree* family or the QTable* one? For example, I could use a QTreeWidget and call setRootIsDecorated(false) on it.
    3. It seems easier to implement the Model Class on a QTableView than on a QTreeView. Am I right here?

    What would be the best way to go?

    Thanks in advance for any advice.

    Regards,
    Wladek
    Attached Images Attached Images
    One second is long, everything longer than two seconds is definitely too long.

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

    Default Re: Should I use QTreeView or QTableView?

    The image looks like a QTable* to me. If it has only some rows, I wouldn't implement a own model, just use QTableWidget.

    If you want to show all drives on your computer have a look a QFileSystemModel since Qt provides it and so you don't have to create your own model.

  3. #3
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Should I use QTreeView or QTableView?

    Hi Lykurg,

    Please allow me to explain what I need to do.

    My application (GUI) communicates with a service and receives from it some information about the list of devices (USB, floppy, CD-ROM, etc....).
    I need to parse this information and to display it in the interface.

    I have just read about QStandardItemModel and QStandardItem. Do you think this could be a good approuch?

    Or should I just use, as you said, QTableWidget and populate it from my information?

    Again, thanks in advance,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Should I use QTreeView or QTableView?

    Well, it depends on you. The high end solution and most elegant one is surely the model approach. But there you have to decide: Use a predefined model like the QStandartItemModel you mentioned or write your own. For that see http://doc.trolltech.com/latest/mode...ng-models.html.

    Now, if you only receive little information from that service and the items doesn't change often, my opinion is that a custom model is not worth to use (and code it). Also because you only have to deal with standard informations and nothing special at all.

    So there are only QTableWidget and QStandartItemModel are left. And if I remember right, QTableWidget uses QStandartItemModel internal. So, if you only have one place in your application where you want to show the informations you get from the service, then use a QTableWidget, since it is (for the most people) easier to use. If you have more "places" in your application where you want to show the devices then use QStandartItemModel and pass the model around.

  5. The following user says thank you to Lykurg for this useful post:

    wladek (21st July 2010)

  6. #5
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Should I use QTreeView or QTableView?

    There is only one place where I need to show this list.

    So I decided to use the QTableWidget object and to populate it each time something changes.

    Thanks man.

    Regards,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

Similar Threads

  1. One Model, Two Views (QTreeView and QTableView)
    By dgarrett97 in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 18:10
  2. row height in QTreeView and QTableView
    By yuriry in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 00:58
  3. QTreeView Fixed column & QTableView
    By jpujolf in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2008, 09:35
  4. QTableView vs QTreeView
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2008, 07:17
  5. How to merge QTableView and QTreeView ???
    By Xaleandr in forum Newbie
    Replies: 2
    Last Post: 29th December 2007, 17:58

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
  •  
Qt is a trademark of The Qt Company.