PDA

View Full Version : Probably a simple question on sharing one model between two views



jmalicke
7th November 2014, 19:36
Hi all,

I appreciate all the help you've given me in the past few days. I am doing more complex stuff with Qt now and I truly do appreciate the help you guys offer to guide me on the right direction.

In this case, I am working with legacy code. I have a large deque data structure. This is the data source. I need two QTableView widgets on a single dialog that utilize the same data source but show different columns of data. Since each table displays different columns of data, how can they share the same QAbstractItemModel? Is this what proxy models are for?

Thank you kindly,
Joseph

ChrisW67
7th November 2014, 21:20
The views are free to hide columns independently of each other. See QTableView::setColumnHidden()

You could use a proxy model to do this but generally programmers want the least possible work.

anda_skoa
8th November 2014, 09:50
You can also use two models unless you need the views to share a model, e.g. because they also should share a selection model.

Cheers,
_