Results 1 to 14 of 14

Thread: View using multiple models

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: View using multiple models

    Quote Originally Posted by QtQuery View Post
    Or is it a matter of overriding columnCount() and data() to return the data from the second model in a new column?
    Yes, that's correct - you need to reimplement at least columnCount(), index(), parent() and data() to take extra columns into account.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    QtQuery (31st August 2010)

  3. #2
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: View using multiple models

    Hello,

    i've the same problem, i need to merge 2 tree models into one treeview.
    The first model is a simple QStandardItemModel. The second model is a QDirModel.
    Now i want to display both models into one treeview. So from the posting i think i need an overlay...

    Qt Code:
    1. CustomModel Items
    2. Custom Item 1 (QStandardItemModel)
    3. Custom SubItem 1 (QStandardItemModel)
    4. Custom SubItem 2 (QStandardItemModel)
    5. Custom Item 2 (QStandardItemModel)
    6. Custom SubItem 1 (QStandardItemModel)
    7. Custom SubItem 2 (QStandardItemModel)
    8. DirModel Items
    9. C: (QDirModel)
    10. Qt (QDirModel)
    11. 2010.05 (QDirModel)
    To copy to clipboard, switch view to plain text mode 

    So, i think i need two functions setCustomModel(QAbstractItemModel *pModel); and a function setDirModel(QAbstractItemModel *pModel); for example.
    But how can i handle it that when i click on an item in the QDirModel to display a file content and if i click on an item in the QStandardItemModel to display for example the a string? To simplify this, i want to know how the treeview knows which model must be accessed.

    I've also attached a screenshot of the current situation. In the left (empty) TreeView i will merge the right ones.

    Thanks in advance

    Best Regards
    NoRulez
    Attached Images Attached Images

Similar Threads

  1. QTreeView and multiple models
    By Daher in forum Qt Programming
    Replies: 3
    Last Post: 3rd December 2019, 20:57
  2. QTreeView with multiple models
    By Daher in forum Qt Programming
    Replies: 5
    Last Post: 18th October 2011, 10:53
  3. QSortFilterProxyModel with multiple source models
    By hoshy in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2009, 20:59
  4. Replies: 3
    Last Post: 5th October 2008, 23:41
  5. Proxy models and slection models
    By amunitz in forum The Model-View Framework
    Replies: 1
    Last Post: 23rd September 2008, 14:35

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.