Custom view from QSortFilterProxyModel
-
Hi,
As I've posted a few days ago "here":http://qt-project.org/forums/viewthread/21448, I'm implementing an inventory application. Basic SQLite view and so on was up quite quickly, but as I have many different types of parts, I have relations to another tables which define the certain fieldname for a given part.
Here comes the tricky part for at least me. I want to have a tree-like or maybe a treeview of QTableViews (or something similar, a subclass of it or whatever) of groups of these items based on their types.
So I set up a QSortFilterProxyModel from a QSqlRelationModel and I'm creating a QTableView from these. It's okay, but in order to have the types separated, instead of this, I need to create more QTableViews from temp QSortFilterProxyModels from my base QSortFilterProdyModel and keep track of these (add to my layout and destroy them, if not needed anymore) as I want to be able to dinamically filter them in runtime.
Any ideas how could I implement this in a elegant way? Thanks for you help :)
-
A quick update regarding my problem:
I managed to kinda make it work. Basicly when search slot is called, I'm doing the following:
Check if my base proxymodel is empty, if yes, return
Check if my QVectors that are storing my dinamically created further filtered ProxyModels and QTableViews are empty, if not, removing all of them from the UI and destroying them
Creating a QStringList that I fill up with part types
Iterate trough the above mentioned QStringList and create as many QTablesViews as many partTypes I have. Every QTableView gets a further filtered (subclassed) QSortFilterProxyModel.
Store the dinamically created objects
Update the UI by adding the newly created widgets.
I know, that maybe it isn't the best way, but I haven't done anything like this so far. I was looking at delegates, but I'm not sure how to reimplement the above mentioned features, however I think it would be faster.
Later I'll post some code too, but right now it's a little messy. Meanwhile, if you have any suggestions, please let know. :)