Results 1 to 7 of 7

Thread: Two Trees in one View

  1. #1
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Two Trees in one View

    Hello!

    I am having trouble with implementing a view with two trees beside one another.Each tree should have more than one column. The trees are separated byone column. This columns purpose is to display compare symbols.So two trees that can be compared in one view.

    Here is a sample picture.




    What would be the best approach for this problem?

    Thank you for your answers.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Two Trees in one View

    One way is to place two QTreeViews besides each other:
    keep the expanded items in sync (if you want)
    keep the scroll positions synced
    You need to connect to QTreeView::collapsed() / expanded; and
    probably need to subclass QTreeView to override QAbstractScrollArea::scrollContentsBy() (in order to keep both views at the same y coordinate).

    HTH

  3. #3
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Two Trees in one View

    Thank you for your answer.I also thought about that but the problem is that i need to have joust one view.

  4. #4
    Join Date
    Jan 2008
    Location
    Warsaw
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Two Trees in one View

    Maybe you could try making your own model which will be mapping data from second treeview to indices begining from third column. I guess it'll solve scrolling and expanding problem.
    Last edited by zatoichi; 26th January 2009 at 23:20.

  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: Two Trees in one View

    Quote Originally Posted by kemp View Post
    Thank you for your answer.I also thought about that but the problem is that i need to have joust one view.
    QTreeView doesn't support two independent sets of columns and two independent sets of rows which is what you want. So either you will use two trees and make them look like one (which is possible) or you'll have to implement your own view based on QAbstractItemView.

  6. #6
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Two Trees in one View

    Thank you for your answer. I will try.

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Two Trees in one View

    Quote Originally Posted by kemp View Post
    the problem is that i need to have joust one view.
    Just curious, where does such requirement come from?
    J-P Nurmi

Similar Threads

  1. Graphics View Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 08:17
  2. World View Zooming factor
    By Pharell in forum General Programming
    Replies: 0
    Last Post: 6th November 2008, 14:04
  3. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 20:21
  4. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 09:50
  5. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 14:01

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.