Mine
public cpp v1 · immutablebool MerchandiseCartModel::setData(const QModelIndex& index, const QVariant& value, int role){ if(index.isValid()) { switch(role) { case Qt::DisplayRole: { // merchandise text, price and quantity set return true; } case Qt::DecorationRole: { // merchandise image set return true; } default: { // other roles handlng } } // switch } else { // index not valid, returns false return false; // unsuccsesfull }