PDA

View Full Version : Closing all editors in a view?



smacchia
10th April 2007, 13:46
Is there a way for a view (i.e., QTableView) to "close all editors" ? I have a derivation but there is no method to call to "close all editors" and no of knowing who the editors are (QAbstractItemView knows in its internal data structures, but this is kept private). I don't want to use the focus out event in the delegate's event filter because it causes other behaviors that I don't want (i.e., I don't want to comit the edit on focus out or hide).

The hide event doesn't come through to the event filter...

This is Qt4

smacchia
10th April 2007, 14:09
In MyView::hideEvent (MyView is derived from QTableView), I tried:

closePersistentEditor(currentIndex());
QTableView::hideEvent(event); // let base class to do its thing too.
When I do this, it closes the editors. Then when I "show" the table again, I can't get focus on any of the cells and have to click quite a bit to get another editor. This is very puzzling...

smacchia
10th April 2007, 14:29
After more investigation, I found that the delegate event filter IS getting called for hide events, so this is the right place to "emit closeEditor(...)". Thus, problem solved (and sorry for the post when I solved it myself! but I was struggling with this for the last day...)

:)