Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [CLOSED] Qtreeview multilevel child auto select
Forum Updated to NodeBB v4.3 + New Features

[CLOSED] Qtreeview multilevel child auto select

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • 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.
  • X Offline
    X Offline
    XGuy
    wrote on last edited by
    #1

    how to implement a recursive function to auto select all the children of a root item inside QTreeview model and then give user, the ability to deselect each one he wishes!
    Note: each child also can have children. deselect occurs one by one.

    below code selects all the children successfully but i don't know how to implement deselect !!

    @QObject::connect(ui->trvView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemSelected(QModelIndex)));@

    @void TrustChain::itemSelected(QModelIndex index)
    {
    QModelIndex childIndex;
    if(!index.isValid())
    {
    return;
    }

    selectedItem = chainModel->itemFromIndex(index);
    if(!selectedItem)
    {
        return;
    }
    
    ui->trvView->selectionModel()->select(index, QItemSelectionModel::Select);
    for(int i = 0; i < selectedItem->rowCount(); i++)
    {
        childIndex = chainModel->index(i, 0, index);
        ui->trvView->selectionModel()->select(childIndex, QItemSelectionModel::Select);
        itemSelected(childIndex);
        while (selectedItem->parent() != 0)
        {
            selectedItem = selectedItem->parent();
        }
    }
    

    }@

    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