Results 1 to 8 of 8

Thread: QStandardItemModel to TableView

  1. #1
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QStandardItemModel to TableView

    Dear All

    I have QStandardItemModel which has several leafs. Like

    A
    -A1
    -A2
    B
    -B1
    --B11
    --B12
    -B2
    --B21
    +C
    +D
    -E
    -E1

    What i would like to do is i want to create a table with these values like
    A
    A1
    A2
    B
    B1
    B11
    B12
    B2
    B21
    C
    D
    E
    E1

    I have search the from and see that people sugested QAbstractProxyModel but except the TransposeProxyModel i wasnt able to find anything. C

    Can you please help me?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStandardItemModel to TableView

    You need to implement a proxy model that will flatten your model. If item A has children A1 and A2, they have to be moved below their parent. Thus the row number of B' will increase by the number of children A has, etc.
    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
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStandardItemModel to TableView

    Can any body help me to find out in the mapToSource function if the item has isExpanded or not???

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStandardItemModel to TableView

    There is no concept of "expanded" items in the model. It's a feature of the 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.


  5. #5
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStandardItemModel to TableView

    Dear Wysota

    What i am trying to do is, from the tree view, i would like to get the expaned items in the maptosource function?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStandardItemModel to TableView

    And what is stopping you from doing that? QTreeView::isExpanded() returns information whether the view shows a particular index as expanded or not.
    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.


  7. #7
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStandardItemModel to TableView

    The problem is i cant get the treeitem to the maptosource...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStandardItemModel to TableView

    You can store a pointer to the tree in the proxy model and then retrieve and use it in mapToSource and mapFromSource if you really have to.
    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. using QStandardItemModel
    By GrahamLabdon in forum Newbie
    Replies: 1
    Last Post: 6th March 2011, 09:13
  2. QTreeView with QStandardItemModel
    By aekilic in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2011, 09:11
  3. QStandardItemModel doubt.
    By rex in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2011, 11:36
  4. Best practices concerning QStandardItemModel
    By tim47 in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2010, 05:29
  5. QStandardItemModel Help
    By frenk_castle in forum Newbie
    Replies: 1
    Last Post: 16th January 2010, 17:54

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