How to link two data sources with QListView?
I would like to know how to set two data sources with QListView.
I am facing that problem.
Firstly, I used QSqlQueryModel as a data source for QListView.
sqlModel.setQuery(SELECT * FROM.....);
Later, myListView need to add another data source from XML parser.
I would like to do.
But both of them has same data structure (same columns)
Thanks you, all
In my opinion you should you should write your own QAbstractItemModel derived model which should combine QSqlQueryModel and XML data.This new model should be passed to QListView.
You cannot use multiple models on a view.
However, you can create your on QAbstractItemModel or QProxyModel which supports mutiple source models (which basically boils down to index mapping).
Be aware that working with SQL models can be tricky, as model metadata such as QSqlQueryModel::rowCount() might report inaccurate data (depending on the supported features of your underlying database).
You also might consider just feeding a QStandardItemModel with the values from your source models but doing so you will lose all the advantages of the source models (ie. caching) - which might lead to serious performance implications.
Thanks for all advices.
I made myModel & set to QListView.
It lead to significant performance.
Previously I used,
Then, I made myModel from QStandardItemModel to accept two data sources.
although, tested with same data, 2nd method caused very bad performance.
During my debugging with timer, it showed that same result upto QListView.setModel();
I thought that, bad performance may be during paint event of QListView.
Is it correct?
How can I fix that?
[quote author="zither" date="1310885907"]I thought that, bad performance may be during paint event of QListView. Is it correct?[/quote]
[quote author="zither" date="1310885907"]How can I fix that?[/quote]
You can't. See "here":http://developer.qt.nokia.com/forums/viewthread/7835/#46011.