Results 1 to 5 of 5

Thread: single Qt model/view different trees

  1. #1
    Join Date
    Mar 2014
    Posts
    9
    Thanks
    5
    Qt products
    Qt5

    Default single Qt model/view different trees

    So I basically want to achieve sth like this:

    Qt Code:
    1. |view1
    2. |- file1
    3. | |- item1
    4. | |- item2
    5. |- file2
    6. | |- item3
    7. | |- item4
    8. |+ file3
    9. ...
    10.  
    11. view2
    12. |- item1
    13. |- item2
    14. |- group1
    15. | |- item3
    16. | |- group2
    17. | |- item4
    18. |- item5
    19. ...
    To copy to clipboard, switch view to plain text mode 

    with 1 model. Is it possible?

  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: single Qt model/view different trees

    It depends whether "item1" from view1 and "item1" from view2 are supposed to be the same item or not. If yes then you need to go through an additional proxy model. If not then yes, it is possible directly by setting different root indexes in each view.
    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.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: single Qt model/view different trees

    The question is: why one model?

    Cheers,
    _

  4. #4
    Join Date
    Mar 2014
    Posts
    9
    Thanks
    5
    Qt products
    Qt5

    Default Re: single Qt model/view different trees

    Quote Originally Posted by wysota View Post
    It depends whether "item1" from view1 and "item1" from view2 are supposed to be the same item.
    Yes pretty much they are. I'll have a dip into this proxy model, even though technically it's another model isn't it?

    Quote Originally Posted by anda_skoa View Post
    The question is: why one model?
    Because I want them to be bound, so let's say I select a group of items in view2, and I want these items to be selected in view1 and the group to be selected in my custom QGraphicsView. I want to be able to hide these items using both of the views etc. So it seems to make most sense using model/view approach.

  5. #5
    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: single Qt model/view different trees

    Quote Originally Posted by Bziur View Post
    Yes pretty much they are. I'll have a dip into this proxy model, even though technically it's another model isn't it?
    Yes, however there is only one set of data and one place where the data is managed.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 29th August 2013, 05:41
  2. Replies: 4
    Last Post: 18th April 2012, 18:11
  3. Multiple model to single view
    By moh.gup@gmail.com in forum Qt Programming
    Replies: 4
    Last Post: 9th March 2012, 09:57
  4. Converting to Model/View from hard-coded trees and tables
    By d_stranz in forum Qt Programming
    Replies: 0
    Last Post: 6th March 2012, 17:46
  5. Two Trees in one View
    By kemp in forum Qt Programming
    Replies: 6
    Last Post: 27th January 2009, 15:00

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.