How to get all data from qt model
<p>I have created a QIdentityProxyModel called proxymodel that extends a QSqlTableModel called sourcemodel by adding 3 calculated columns. 
The calculated columns are made by traversing the sourcemodel and storing the data in a list that is mapped by the proxymodel.
The proxymodel is displayed in a TableView.</p>

<p>The problem i have is that unless i interact with the TableView the models only load the first 256 registers of 5426 total, so initially i can only perform calculations on these first 256 rows.</p>

<p>I wish to fill the list with the calculations on the 5426 row.
please! help me get this done? Any ideas woukd be helpful</p>

<p>The project is written in pyqt so be free to answer however you want!</p>

<p>SQL models use the progressive fetch. The source model returns <code>true</code> from <code>canFetchMore</code>. The view calls <code>fetchMore</code>, and then more rows are added to the source model by fetching them from the database - only when the view needs them.</p>

<p>Since your proxy needs all the data, it should invoke <code>fetchMore</code> on the source model during idle time (using a zero-duration timer). It should also properly track the source getting more rows inserted to it!</p>

<pre><code>class MyProxy : public QIdentityProxyModel {
  Q_OBJECT
  QMetaObject::Connection m_onRowsInserted;
  ...
  /// Update the computed results based on data in rows first through last
  /// in the source model.
  void calculate(int first, int last);
  void onRowsInserted(const QModelIndex &amp; parent, int first, int last) {
    calculate(int first, int last);
  }
  void onSourceModelChanged() {
    disconnect(m_onRowsInserted);
    m_onRowsInserted = connect(sourceModel(), &amp;QAbstractItemModel::rowsInserted,
                               this, &amp;MyProxy::onRowsInserted);
    fetch();
  }
  void fetch() {
    if (!sourceModel()-&gt;canFetchMore(QModelIndex{})) return;
    QTimer::singleShot(0, this, [this]{
      if (!sourceModel()-&gt;canFetchMore(QModelIndex{})) return;
      sourceModel()-&gt;fetchMore(QModelIndex{});
      fetch();
    });
  }
public:
  MyProxy(QObject * parent = nullptr) : QIdentityProxyModel{parent} {
    connect(this, &amp;QAbstractProxyModel::sourceModelChanged,
            this, &amp;MyProxy::onSourceModelChanged);
  }
};
</code></pre>

python c++ qt model