1

When I set data from QML to model, how can I check returned value of setData method?

For example:

QML:

delegate:
   CheckBox {
   id: selCheckbox

   onCheckStateChanged: { 

      // This call setData method
      itemSelected = checked 

      // And HERE I need check returned value from setData method.
   }
}

C++:

class EditedListModel: public QAbstractListModel 
{

    bool EditedListModel::setData( const QModelIndex &index, const QVariant &value, int role )
    {
       bool retVal = false;

       if( index.isValid() )
       {
         // Some condition which allows item selection 
           if( ... )
                m_ItemSelected[index.row()] = data.toBool();
       }
       return retVal;
    } 
}
  • 1
    What your code should explain? I see no place where you call to `setData`. What is `EditedListModel`? Please provide [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Ah, and .. yes, welcome to SO -) – folibis Feb 27 '19 at 12:55
  • Possible duplicate of [Access C++ function from QML](https://stackoverflow.com/questions/9500280/access-c-function-from-qml) – TrebledJ Feb 27 '19 at 13:53
  • @folibis `itemSelected = checked` calls the `setData` method of the model – GrecKo Feb 27 '19 at 14:49

0 Answers0