Results 1 to 6 of 6

Thread: QTreeView with multiple models

  1. #1
    Join Date
    Apr 2008
    Posts
    3

    Default QTreeView with multiple models

    Hello,

    I have three models getting a tree of objects from three different databases. The interface designer is suggesting that we collect the 3 trees into subtrees in one page instead of having 3 pages for each set of data.

    the only choice i can see right now is to setup a 4th model which will use every model for its own subtree, but this seems too harsh to implement. I was wondering if someone can give me a hint about a simpler solution.

    Thanks in advanced.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView with multiple models

    cant u make the 3 database info as one node of the tree

    Something like -
    Root
    + DB 1
    + DB 2
    + DB 3

    where each of the branches can be expanded acc to the databases ???

  3. #3
    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: QTreeView with multiple models

    Quote Originally Posted by Daher View Post
    the only choice i can see right now is to setup a 4th model which will use every model for its own subtree, but this seems too harsh to implement. I was wondering if someone can give me a hint about a simpler solution.
    The simplest idea I can think of is to implement a simple proxy model that will add three fake top-level items and serve their children from real models. Shouldn't be more than 30 lines of code...

  4. #4
    Join Date
    Apr 2008
    Posts
    3

    Default Re: QTreeView with multiple models

    I'm facing a problem

    in mapFromSource() the parameter 'index', i don't seem to be able to identify which source it is from. so that when i mapToSource() i will send it back to the correct source.

  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: QTreeView with multiple models

    You have three models so reimplementing mapFromSource() is not enough.

  6. #6
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTreeView with multiple models

    Quote Originally Posted by wysota View Post
    The simplest idea I can think of is to implement a simple proxy model that will add three fake top-level items and serve their children from real models. Shouldn't be more than 30 lines of code...
    It would be cool to get more detail on this topic...

Similar Threads

  1. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23
  2. [QT4] QTreeView and rows with multiple lines
    By KShots in forum Qt Programming
    Replies: 8
    Last Post: 30th March 2006, 18:47
  3. Replies: 2
    Last Post: 10th March 2006, 18:04

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.