title: how to write setdata() in qsqlquerymodel(QAbstractItemModel)?
body: <p>I've made <code>myModel</code> using <strong>inheritance</strong> (<code>QSqlQueryModel</code>) and I
   insert column into it. I want insert data of type <code>QString</code>, but I don't know how to do.</p>
  
  <p><code>QSQlQueryModel</code> is read-only model. To make it read-write, you must subclass it and reimplement <code>setData()</code> and <code>flags()</code>.</p>
  
  <p>I want to override these two methods and here is what I've done so far:<br>
  <strong>dialog.cpp:</strong></p>
  
  <pre><code>this-&gt;model = new myModel(this);
  model-&gt;setQuery("SELECT * lists");
  model-&gt;insertColumn(3);
  model-&gt;setHeaderData(3, Qt::Horizontal, QObject::tr("string"));
  qDebug() &lt;&lt; model-&gt;setData(model-&gt;index(0,3),"string",Qt::EditRole);
  // column add, column set data using setdata()
  ui-&gt;tvGameList-&gt;setModel(model);
  </code></pre>
  
  <p><strong>myModel.h:</strong></p>
  
  <pre><code>class myModel : public QSqlQueryModel
  {
  
      Q_OBJECT
  
  public:
      myModel(QObject *parent = 0);
      Qt::ItemFlags flags(const QModelIndex &amp;index) const Q_DECL_OVERRIDE;
      bool setData(const QModelIndex &amp;index, const QVariant &amp;value, int role) Q_DECL_OVERRIDE;
  
  };
  </code></pre>
  
  <p><strong>myModel.cpp:</strong></p>
  
  <pre><code>#include "mymodel.h"
  #include &lt;QSqlQuery&gt;
  
  myModel::myModel(QObject *parent): QSqlQueryModel(parent)
  {
  }
  
  Qt::ItemFlags myModel::flags(const QModelIndex &amp;index) const
  {
      Qt::ItemFlags flags = QSqlQueryModel::flags(index);
      if (index.column() == 1 || index.column() == 2)
          flags |= Qt::ItemIsEditable;
      return flags;
  }
  
  bool myModel::setData(const QModelIndex &amp;index, const QVariant &amp;value, int role = Qt::EditRole)
  {
      if (index.isValid() &amp;&amp; role == Qt::EditRole)
      {
          // I don't know here
          emit dataChanged(index, index);
          return true;
      }
      return false;
  }
  </code></pre>