How to insert data rows to QProxyModel?
-
wrote on 31 Jul 2011, 16:45 last edited by
@this->beginInsertRows(QModelIndex(),this->rowCount(),List.length());
for (int i=0;i<List.length();i++){
this->insertRow(this->rowCount(),QModelIndex());
this->setData(this->index(this->rowCount(),0),QString("TEST"),Qt::DisplayRole);}
this->endInsertRows();@I can't insert with above code..
How can I insert QList<QStandardItem*> List into that QProxyModel?
Or need another QList<????*> List ?Thanks
-
wrote on 31 Jul 2011, 17:14 last edited by
Hi zither,
If the proxy model is the QSortFilterProxyModel it will call the source modles functions for that. If the source model does not support inserting rows, it will do nothing.
Or do you have a custom implemented proxy model? then perhaps, it's missing some implementation...
-
wrote on 31 Jul 2011, 17:22 last edited by
Hi Gerolf,
I'm making custom QProxyModel which source Model is QSqlQueryModel, I would like to add new rows to QProxyModel which will show to QListView.
@QSqlQueryModel -> QProxyModel ->QListView;@
How can I insert new rows for that?Thanks
-
wrote on 31 Jul 2011, 17:30 last edited by
insertRows empty implementation does nothing. You have to do the insert pon your own, so e.g. call the source models insertRow function instead of the base implementation.
-
wrote on 31 Jul 2011, 17:47 last edited by
My Source Model is QSqlQueryModel which is read-only..
So, I have to change type of my source Model?
Is there any model which can handle one data source & inserting of data via Model? -
wrote on 31 Jul 2011, 18:13 last edited by
What do you try to achieve?
Do you just want to insert data temporarily? then QProxyModel is a a possibility. But you have to handle it on your own. There is no default model for such things. You have abstract models (only base classes), proxy models (QSFPM) which do not implement inserting data by default, SQL models which allow inserting data but that is only possible if the model is not readonly.
-
wrote on 31 Jul 2011, 18:20 last edited by
I made a search method for SQLite Database.
So, I choose QSqlQueryModel as it source. Then, I need to insert some XML data from another at the same time. So, I have to insert new rows to that Model which link to ModelView.Plz help me to pass that problem...
Thanks
-
wrote on 31 Jul 2011, 18:46 last edited by
Why are you starting a new topic on that? You have several topics on this already. Please stick to one topic for one question.
6/8