title: Why would QSortFilterProxyModel.setData() return false?
body: <p>I have created a QSortFilterProxyModel off of my QSqlTableModel and have successfully added an extra column to it so that I can add a difference field that would be a waste of space in the database table.</p>
  
  <p>However, the setData function off of the proxy model instance is returning false. No other compile or runtime errors are occuring.</p>
  
  <pre><code>QSortFilterProxyModel *balanceProxyModel = new QSortFilterProxyModel(this);
  balanceProxyModel-&gt;setSourceModel(balanceModel);
  
  // add a Diff column
  balanceProxyModel-&gt;insertColumn(6);
  balanceProxyModel-&gt;setHeaderData(
    6, Qt::Horizontal, QObject::tr("Difference"));
  
  for (int i = 0; i &lt; balanceProxyModel-&gt;rowCount(); ++i) {
    float budget = balanceProxyModel-&gt;index(i, 4).data().toFloat();
    float actual = balanceProxyModel-&gt;index(i, 5).data().toFloat();
    float difference = budget - actual;
  
    if (balanceModel-&gt;setData(
        balanceModel-&gt;index(i, 6), QVariant(difference)) == false) {
      qDebug() &lt;&lt; ATLINE &lt;&lt; ":"
        &lt;&lt; "diff not added!!!";
    }
  </code></pre>
  
  <p>For each record I am getting "diff not added!!!" since setData is failing (returning false.)</p>
  
  <p>Thanks.</p>
  
  <p>--update 20110907_0754--
  I tried ixM's suggestion, and fixed a minor error, but it didn't fix the issue. I'm still getting "diff not added" (or false back from the setData function.)</p>
  
  <pre><code>if (balanceProxyModel-&gt;setData(
      balanceProxyModel-&gt;index(i, 6), QVariant(difference)) == false) {
    qDebug() &lt;&lt; ATLINE &lt;&lt; ":"
      &lt;&lt; "diff not added!!!";
  }
  </code></pre>
  
  <p>--update 20110907_2205--
  I added the following (by the way, the Difference field does show up):</p>
  
  <pre><code>qDebug() &lt;&lt; "balanceProxyModel-&gt;insertColumn(6);";
  qDebug() &lt;&lt; balanceProxyModel-&gt;insertColumn(6);
  </code></pre>
  
  <p>And got the following results to stdout:</p>
  
  <pre><code>Debug: balanceProxyModel-&gt;insertColumn(6); 
  Debug: true 
  </code></pre>
  
  <p>Later, I added the following to the loop:</p>
  
  <pre><code>qDebug() &lt;&lt; "balanceModel-&gt;index(i, 6);";
  qDebug() &lt;&lt; balanceModel-&gt;index(i, 6);
  </code></pre>
  
  <p>to stdout:</p>
  
  <pre><code>Debug: balanceModel-&gt;index(i, 6); 
  Debug: QModelIndex(128,6,0x0,QSqlTableModel(0x1d10bf0) )  
  </code></pre>
  
  <p>--update 20110908_2153--
  Hmm, I didn't consider setting properties on the column. Here's the result of your test:</p>
  
  <pre><code>qDebug() 
    &lt;&lt; (bool)(balanceProxyModel-&gt;flags(diffModelIndex) &amp; Qt::ItemIsEditable) 
    &lt;&lt; (bool)(balanceProxyModel-&gt;flags(diffModelIndex) &amp; Qt::ItemIsEnabled);
  </code></pre>
  
  <p>results:</p>
  
  <pre><code>Debug: false true 
  </code></pre>
  
  <p>From the test that ixM suggested, the results are showing that Qt::ItemIsEditable is false. That answers my actual question. Of course I'm left wondering just how to set that flag. The model index class has no method that I can see that allows setting the flags. Perhaps at this point I should look at subclassing the proxy class to get it to allow editable columns.</p>