Can i attach to QStandardItem check state a signal to know its state ? without subclassing.

  • Hi
    i have simple QStandardItem that one of its column is setCheckable(true);
    i didnt found any signal i can attach to it , so i could trigger function on check box state .
    how can i attach one without sub classing the QStandardItem.

  • its not working for me .
    here what i have :

    @connect(ui.treeView_mainwindow, SIGNAL(itemChanged( const QModelIndex &)), this,
    SLOT(tree_itemChanged( const QModelIndex &)));

    // this function never fired when i check in/out
    tree_itemChanged(const QModelIndex & index)

     QStandardItem* standardItem  = m_model->itemFromIndex(index);
     Qt::CheckState checkState = standardItem->checkState();
     if(checkState == Qt::Checked)
     else if(checkState == Qt::Unchecked)


  • itemChanged is a signal from QStandardItemModel, not from (I think) a QTreeView

    The signature is wrong as well (it passes a QStandardItem* and not a QModelIndex).

    Tip: when developing, enable debug and check the console. A connect() that fails will return false and print a warning on the console.

  • Thanks working

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.