Results 1 to 3 of 3

Thread: QTreeView items in line

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeView items in line

    Is it possible to display children of the top root in line (horizontally instead of line by line)

    If that is possible using any of delegate technics please can some one share any of that option, pointing me to the right direction !?

    -root1
    - child - child - child

    -root2
    - child - child - child

    Thank you

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeView items in line

    Parent and Child are the concepts of arranging the data on the screen (view) is a hierarchy, it is not required to store parent and child in a hierarchy data structure, this is a main and powerful feature exploited by Model/View Framework.

    It may not be possible using delegate, delegate are use to interchange data, and but not to rearrange data (which you want to do in your case)

    Not sure what your trying to display, but whatever it be, it up to you to store the data in what every way you want it be, (any data structure / database / file). Now the your question is to how to display them then given formation.

    The answer would be implement a custom QAbstractItemModel for the QTreeView, and when the view asks to give children and there columns items, then you need to collect all the children and supply to view as if they were a part of one virtual child, and each actual child as a column of the virtual child.

    It is as good as saying (only in your case) that the parent and child terms have different interpretation for a view, and diferent interpretation for you model, that is a child for view is a collection of children for the model.

    This is all about how you design your model, and exploit Model/View Framework, to answer in one line, all you need to do is handle things in model which you implement.

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

    migel (5th June 2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView items in line

    Right now I have this working by implementing QListView into child and have all my items in QListView. But this wont work for me in the feature because I am getting lots of QListView's not interacting to each other. It must be one view when I can select individual or all together childs/items.

    I think I need look into QAbstractItemModel to see how I can supply a view for a child.

    Thanks for explanation.

Similar Threads

  1. Replies: 0
    Last Post: 15th April 2011, 19:04
  2. Replies: 2
    Last Post: 20th August 2010, 05:18
  3. Get rid of the frame around items in the QTreeView
    By THRESHE in forum Qt Programming
    Replies: 3
    Last Post: 10th December 2008, 18:00
  4. QTreeView: Holding a line on screen
    By gri in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 11:42
  5. How to clear All items on QTreeView ?
    By qintm in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2006, 11:39

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
  •  
Qt is a trademark of The Qt Company.