[Qt-interest] Blocking signals from / to MVC components.

MARTIN Pierre hickscorp at gmail.com
Wed Sep 21 03:31:28 CEST 2011


Hello again list subscribers,

i have an interesting question about the overall MVC behavior in Qt (4.7.3, OpenSource).
Let's say you have a view of any kind (In my case, a simple QListView), item-based. Connected to this view is an abstract item model based model (In my case, a QSqlTableModel).

In the table the QSqlTableModel is working on, there are two kinds of columns: the ones which are displayed in the list (And thus are editable directly via delegates), and the ones containing complex data and thus requiring widgets to be displayed for edition upon click on a list item.

The thing is, i choose to use various editing fields and there is a "Save" button (As opposed to a "Revert" button), which calls setData on columns which are not visible in the list... However, upon save, the list selection is being reset.

i have tried blocking all signals on the selection model and on the model before calling setData (Even if i really feel it's probably not the way to go) without any success.

i also want to avoid the current solution i have, which is to set the selection to it's previous value after saving...

Would it be anything interesting about this matter, which is avoiding loosing selection on connected views upon setData calls on models?

Thanks,
Pierre.




More information about the Qt-interest-old mailing list