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. Checkableproxymodel - programmatically uncheck a node
Forum Updated to NodeBB v4.3 + New Features

Checkableproxymodel - programmatically uncheck a node

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • P Offline
    P Offline
    phamtv
    wrote on last edited by
    #1

    I am using Checkableproxymodel example by Andres. I need to check/uncheck files and directories based on a list. I cannot seem to programmatically uncheck a file node using the following:
    @
    QDirIterator it(...);
    while (it.hasNext())
    {
    it.next();

        if(ignoredDir.contains(it.filePath().remove(getTestDir() + "/"), Qt::CaseSensitive))
        {
            QModelIndex idx = fsModel->index(it.filePath(), CheckableProxyModel::COL_FILE_NAME);
            m_checkProxy->setData(m_checkProxy->mapFromSource(idx), false, Qt::CheckStateRole);
            continue;
        }
        else
        {
            if (ignoredTest.contains(it.fileName(), Qt::CaseSensitive))
            {
                qDebug() << "Unchecking " << it.fileInfo().filePath();
                QModelIndex idx = fsModel->index(it.fileInfo().filePath(), CheckableProxyModel::COL_FILE_NAME);
                fileTree->setExpanded(m_checkProxy->mapFromSource(idx), true);
                fileTree->setCurrentIndex(m_checkProxy->mapFromSource(idx));
                m_checkProxy->setData(m_checkProxy->mapFromSource(idx), false, Qt::CheckStateRole);
                return;
            }
        }
    }
    

    @

    I can highlight the specific file node using the above but unchecking (line 20), actually unchecks the parent directory instead of the specific file node. Please help.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Why don't you use the methods provided for that: setSourceIndexCheckedState() and setCheckedState().

      1 Reply Last reply
      0
      • P Offline
        P Offline
        phamtv
        wrote on last edited by
        #3

        thanks Andre!

        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