Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QStandardItem - parent-child with multiple columns
QtWS25 Last Chance

QStandardItem - parent-child with multiple columns

Scheduled Pinned Locked Moved Language Bindings
3 Posts 2 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    ManasQt
    wrote on last edited by
    #1

    Hi All,
    I am trying to get the out put which resembles QDireFileModel like below diagram
    how to get this, please help me.

    @

    class MyClass:
    name="A"
    lName="B"

    I tried :
    parent= QStandardItem("parent1")
    model.appendRow(parent)
    for index in range(10):
    myobj=MyClass()
    child= QStandardItem(myobj.name)
    parent.setChild(index,1,myobj)

               child= QStandardItem(myobj.lName)
               parent.setChild(index,2,myobj)
    

    col-0 col-1 col-2 col-3 col-N

    -Parent-1
    -child1 ..... ..... .......
    -child2 ..... ..... .......
    -child3 ..... ..... .......
    ......... .... ..... ......
    -child-N .... ..... ......
    -Parent-2
    -child1 ..... ..... .......
    -child2 ..... ..... .......
    -child3 ..... ..... .......
    ......... .... ..... ......
    -child-N .... ..... ......
    -child-N .... ..... ......
    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      ManasQt
      wrote on last edited by
      #2

      Hi All,

          please can any one tell me how to get this. 
      

      Am i doing it wrong????????????

      Thanks in advance.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spmno
        wrote on last edited by
        #3

        Thank you for you question, I found that you used the wrong column index in your code.

        I try the code below is worked.

        parent= QStandardItem("parent1")
        model.setItem(parent)
        for index in range(10):
        myobj=MyClass()
        child= QStandardItem(myobj.name)
        parent.setChild(index,0,myobj)

                   child= QStandardItem(myobj.lName)
                   parent.setChild(index,1,myobj)
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved