Results 1 to 4 of 4

Thread: qtreeview - subitems don't

  1. #1
    Join Date
    Jul 2008
    Location
    EU , Poland, Zabrze
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question qtreeview - subitems don't

    Hello

    I'm trying to use appendRow to create the following structure with 2 columns
    Items in column called "group" can have children.

    I can do it ok for "group" column - but i have troubles adding "cost" column values

    Qt Code:
    1. |group | costs
    2. ------------------------------
    3.  
    4. Peter | 10
    5.  
    6. Family 1 | 55
    7. --------John | 15
    8. --------Jack | 20
    9. --------Amie | 20
    10.  
    11. Paul | 15
    To copy to clipboard, switch view to plain text mode 

    I hope the structure is clear.
    I don't have troubles adding the cost for "peter" nor Paul but I don't know how to add a second column value for the members of "Family 1"
    when I have

    QList<QStandardItem *> items;
    items << costs_for_john_item;
    john_item->appendColumn(items);
    it creates another subrow for John and does not enter the second column at all.

    by model.setData using row and column numbers I can't edit any value for members of Family 1 group howeveer it works for Peter, John and "family 1" and their costs.

    any advices?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtreeview - subitems don't

    Could you post a compilable example so we can identify the problem more easily? The code you posted is rather terse. Also, instead of the quote tag, you should use the code tag if you post code.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jul 2008
    Location
    EU , Poland, Zabrze
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qtreeview - subitems don't

    Qt Code:
    1. QList<QStandardItem *> items,items2;
    2.  
    3. model_drzewa= new QStandardItemModel;
    4.  
    5. QStandardItem *z1_1 = new QStandardItem( "Peter" );
    6. QStandardItem *z1_2 = new QStandardItem( "Family" );
    7. QStandardItem *z1_3 = new QStandardItem( "Paul" );
    8. QStandardItem *z2_1 = new QStandardItem( "John" );
    9. QStandardItem *z2_2 = new QStandardItem( "Jack" );
    10. QStandardItem *z2_3 = new QStandardItem( "Amie" );
    11. QStandardItem *z1_1_costs = new QStandardItem( "first 1 costs" );
    12. QStandardItem *z2_1_costs = new QStandardItem( "second 1 costs" );
    13.  
    14. model_drzewa->invisibleRootItem()->appendRow(z1_1);
    15. model_drzewa->invisibleRootItem()->appendRow(z1_2);
    16. z1_2->appendRow(z2_1);
    17. z1_2->appendRow(z2_2);
    18. z1_2->appendRow(z2_3);
    19.  
    20. items <<z2_1_costs;
    21. z2_1->appendColumn(items); //why does it create another subitem instead of a parallel column ?
    22.  
    23.  
    24. model_drzewa->invisibleRootItem()->appendRow(z1_3);
    25. model_drzewa->setHorizontalHeaderLabels( QStringList() << "Zlecenia" << "costs" );
    26. ui->treeView->setModel(model_drzewa);
    27. ui->treeView->expandAll();
    28. ui->treeView->model()->setData(ui->treeView->model()->index(0,1),QVariant("first 1 costs wariant"));
    29.  
    30. ui->treeView->model()->setData(ui->treeView->model()->index(0,1).child(0,0),QVariant ("testing if i can change it like that"));
    31. //no i can't
    To copy to clipboard, switch view to plain text mode 

    and the effect is

    instead I would expect "second 1 costs" to be in parallel with John in the second column

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: qtreeview - subitems don't


Similar Threads

  1. Help ...QTreeView
    By Raymond in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2009, 09:18
  2. QTreeView. Qt.4.4.1
    By janEUcitzen in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2008, 08:53
  3. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  4. QTreeView
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 29th May 2007, 08:38
  5. UICTable listview subitems with java
    By cqtkitty in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 08:59

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.