Hi everybody,

I am having a problem with a custom model. I started with a code where a QTreeView was connected to a customized QStandardItemModel. Everything worked great until an idiot (me) wanted to implement a custom proxy from QAbstractProxyModel and messed things up.

In order to get the new insertions from the model, I connected the rowsInserted() signal:

Qt Code:
  1. TreeProxy::TreeProxy ( QStandardItemModel * parent ) :
  2. {
  3. setSourceModel( parent );
  4.  
  5. bool ok;
  6. ok = connect( sourceModel(),
  7. SIGNAL (rowsInserted ( const QModelIndex & , int , int ) ),
  8. this,
  9. SLOT (slot_inserted_rows_for_my_proxy ( const QModelIndex & , int , int ) ));
  10. Q_ASSERT(ok)
To copy to clipboard, switch view to plain text mode 

The first thing I noticed was that the model was not sending the rowsInserted() although the view receives new insertions with no problem at all. The model inherits from QStandardItemModel not from QAbstractItemModel and it does not reimplement appendRow()/insertRow() so I would expect the signal to be OK

I noticed that the proxy receives the signal doing this:

Qt Code:
  1. beginInsertRows(
  2. indexFromItem(parent),
  3. indexFromItem(child_node).row(),
  4. indexFromItem(child_node).row()
  5. );
  6. parent->appendRow(child_node);
  7. endInsertRows();
To copy to clipboard, switch view to plain text mode 

But I would expect the begin/end stuff to be done inside the inherited implementation of appendRow. With that the proxy works and the view fails (blank)

My only solution so far was redeclaring rowsInserted() as a public signal and emit it manually. According the documentation and other questions in this forum, I must not do this. So I wonder what I am doing wrong? What else do I have to do to synchronize a custom proxy and a custom model that inherits a full model implementation?

thanks!