Results 1 to 6 of 6

Thread: QAbstractTableModel for QTreeView?

  1. #1
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QAbstractTableModel for QTreeView?

    I have a QTreeView that really only shows a 2-dimensional dataset. I just think a treeview (really just a list with columns) is more appropriate for this data than a table.

    Still, the Qt documentation tells me that the QAbstractTableModel is not suitable for use with treeviews. Do they only mean hierarchical treeviews? Or is there an incompatibility even for 2D treeviews?

    I'd just like to know that before I start coding.

    Thanks!
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QAbstractTableModel for QTreeView?

    Do they really say that in the docs? Could you quote that? I have never seen such a statement and I've successfully used flat models with tree views many times. You can safely use a table model with a tree view.

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

    Michiel (14th May 2007)

  4. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QAbstractTableModel for QTreeView?

    The exact words are: "Since the model provides a more specialized interface than QAbstractItemModel, it is not suitable for use with tree views, although it can be used to provide data to a QListView."

    But thanks for the answer. I'll go ahead and use the table model.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QAbstractTableModel for QTreeView?

    It means that it can't make use of all its capabilities, because you can't build trees with it.

  6. #5
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QAbstractTableModel for QTreeView?

    Quote Originally Posted by wysota View Post
    It means that it can't make use of all its capabilities, because you can't build trees with it.
    Yes. But you have to admit the quote is misleading. It could also have meant that you just can't use it with a QTreeView.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QAbstractTableModel for QTreeView?

    It's not misleading for me as I know the model is a subclass of a more general model that is usable with a tree. But you are right, you could interprete it in different ways.

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.