Now that we have made our Characters entity model/view aware, we will still need a utility method to add a new character to it. This method will be called add and will take the character's name as an argument.
We will add its declaration to characters.h:
// characters.h#ifndef CHARACTERS_H...class Characters : public QAbstractListModel{...public: ... void add(const QString& name);...}...
Then, we will provide its implementation in characters.cpp:
// characters.cpp...void Characters::add(const QString &name){ if (! m_list.contains(name)) { beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); m_list.append(name); endInsertRows(); }}...
Besides the push_back method of QList (which is equivalent ...