View Full Version : Use of signals and slots with proxy models.

26th April 2013, 22:01

The documentation says the following about proxy models:
The signals and slots used by the model/view framework ensure that each view is updated appropriately no matter how many proxy models are placed between itself and the source model.

Does that mean that the signals and slots are automatically piped through the the proxy models? Or do we still need the connect the signals and slots directely bettween the source model and the view when there are proxy models in between?


26th April 2013, 22:37
Connections are set for you automatically when you call setBaseModel on the proxy.

26th April 2013, 22:39
Your view is connected only to the last model in the chain. Any proxy model is connected to the model before it, takes upstream signals, and maps those signals to corresponding signals for the downstream consumer. Depending the function of the proxy not all upstream signals result in downstream signals and there may not be a one-to-one correspondence.

This mapping occurs for all the QAbstractItemModel signals.

26th April 2013, 23:49
In other words, any signal/slot specific to a QAbstractItemModel sub class (like directoryLoaded() for QFileSystemModel) needs to be connected directely between the source model and the view. Is that what you are saying?

Does that rule also apply for specific class members too?
For example, my source model is a QFileSystemModel and I call isDir() in my View. If there is a proxy model in between, do I need to subclass the proxy model to impement a isDir() function to return to the View whatever the QFileSystemModel source model returns to the proxy model?