I have a sql table with a lot of rows and I need to display this information in 2 different table views on different forms. I want the first view to show a certain set of rows and the second view to show a different, unrelated, set of rows. My first thought is to select all the rows (using a QSqlTableModel) and then use 2 separate QSortFilterProxyModels to filter the data into the 2 views.
In reality my app is more complex then the single table I described above. It has a lot of tables that need the same sort of filter. For performance and resource managing reasons I don't think it's wise to load my entire database into the client's memory. That's where sql SELECT statements make sense, or more specifically QSqlTableModel's setFilter() method.
So now I have two instances of my above model that point to the same sql table but filter only the needed set.
What happens now when the filtered row sets overlap? If the user edits the first model it won't automatically show up in the second model until I call QSqlTableModel::select(), right?
A further idea I had was to go back to a single model and use the setFilter() method to select all of my filtered row sets (for both views) and then use the two QSortFilterProxyModels to filter from there. My problem here is how do I get the two views (or actually the form widgets the views are displayed on) to play nice when using setFilter() since my two views (form widgets) have no knowledge of each other?
Ooh I hope that made sense. The hardest part is defining what the problem is! =)
Bookmarks