Results 1 to 3 of 3

Thread: QModelIndex : Selection of items with expandable items in QTreeView

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QModelIndex : Selection of items with expandable items in QTreeView

    Hi,

    A treemodel is used to display a structure in hierarchical format in QTreeView. The item Checked in the TreeView has to be displayed in a TextBox.

    I am using selectionChanged () as the signal and it passess ModelIndex of the selected item to the slot function.

    The problem is that ModelIndex I can get the row count and the column count (which is zero here).But the count is localized to a specific parent.My problem is that I want a unique representation of the item selected whether be it a parent or child.But what I get is sometimes only the parent string data is accessible sometimes the child.


    void function_slot(QItemSelection &arg,QItemSelection &m)
    {
    Model *model;
    QModelIndex index,k;
    int row;


    QModelIndexList selected =arg.indexes();
    row=index.row();
    foreach(index,selected)
    {
    if(index.isValid())
    {
    row=index.row();
    k=model->index(row,0);
    qDebug<< model->data(l,Qt:isplayRole).toString();
    }
    }
    }

  2. #2
    Join Date
    Feb 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QModelIndex : Selection of items with expandable items in QTreeView

    You mean there's multiple parents so the rows aren't unique?

  3. #3
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QModelIndex : Selection of items with expandable items in QTreeView

    Yes, each row has a parent ,whose child in turn is another parent ..likewise

Similar Threads

  1. QGraphicsScene: selection of multiple items is very slow
    By felixrubio in forum Qt Programming
    Replies: 0
    Last Post: 22nd July 2010, 16:51
  2. QGraphicsScene and Extended Selection of items
    By totem in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2010, 09:37
  3. Custom items selection in qgraphicsscene
    By yonnak in forum Qt Programming
    Replies: 7
    Last Post: 28th March 2009, 12:32
  4. Adding items to a QGraphicsScene's selection list?
    By mooreaa in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2008, 21:01
  5. QTreeView and expandable items
    By SiLiZiUMM in forum Qt Programming
    Replies: 6
    Last Post: 29th April 2008, 14:21

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.