Results 1 to 6 of 6

Thread: QListView v.s. QTreeView, QTableview, QDirModel [solved]

  1. #1
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QListView v.s. QTreeView, QTableview, QDirModel [solved]

    Hi all,

    A program I am writing is supposed to display a list of files that are in use, using three columns (Name, Type and Options).

    To do this I found the QListView class perfect, because I can simply add columns and items. But now it seems that this is no longer fact in QT 4.

    Using Qt3Support, I managed to get this to work, but I want the code to be maintainable in the future, so I need something else.

    In the QT examples, they use a number of different things like QTreeview, QTableView, QDirModel and stuff like that, but they all use them at the same time so I don't know what does what.

    So can you tell me what I should use to do the same as the old QListView from QT3?

    Thanks in advance
    DrDonut
    Last edited by DrDonut; 5th March 2009 at 12:40.

  2. #2
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QListView v.s. QTreeView, QTableview, QDirModel

    Try to use QListWidget, or QTreeWidget.

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView v.s. QTreeView, QTableview, QDirModel

    QListView has only 1 column but you can use QTreeView (where you can have many columns) with only top level items. It would look like "details" view in Windows Explorer.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView v.s. QTreeView, QTableview, QDirModel

    Or you can use QTreeWidget where you don't need a model, just adding items to QTreeWidget. See the attachment (it's QTreeWidget with 3 columns)
    Attached Images Attached Images
    Last edited by faldzip; 5th March 2009 at 12:40.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListView v.s. QTreeView, QTableview, QDirModel

    Okay thank you both.

    Now I used QTreeView and QStandardItemModel and it works!

    I will look into QTreeWidget for the sake of simplicity, but for now it works

    So thanks!

    DrDonut

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListView v.s. QTreeView, QTableview, QDirModel [solved]

    In my opinion, it's better to use view + model than widget, because you have all the benefits from Model/View architecture, mainly data and it's presentation are clearly divided - so your solution is now ok. But sometimes, when you have to show some simple data temporary in only one place and in one way or something like that then the problem is not worth of doing model for it and much faster way is to use widget like QTreeWidget.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. row height in QTreeView and QTableView
    By yuriry in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 00:58
  2. QTreeView Fixed column & QTableView
    By jpujolf in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2008, 09:35
  3. QTableView vs QTreeView
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2008, 07:17
  4. QDirModel and QTreeView cut and paste
    By Micawber in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2008, 20:16
  5. How to merge QTableView and QTreeView ???
    By Xaleandr in forum Newbie
    Replies: 2
    Last Post: 29th December 2007, 17:58

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.