[PyKDE] Model-View application: view not updated

Sibylle Koczian Sibylle.Koczian at t-online.de
Fri Dec 15 15:17:21 GMT 2006


I'm slowly progressing with my small database application, which means
that I've got a new question.

In its present state the application contains a QTableView with a model
subclassed from QAbstractTableModel. I used the sqlcursorview.py example
from the EuroPython 2006 examples and extended it to get editable
columns. That works so far, with one exception:

Changes in the records shown in the view are either written to the
database or cancelled in one query, so I've got two buttons for this.
The cancel button simply repeats the method call which was used to fill
the view in the first place, the save button writes to the database - in
which case the view can stay as it is. Additionally there is a spin box
that lets the user choose which of several data sets shall be shown in
the view.

The problem is with the cancel button: the changed records are only
changed back after the window lost focus - the view isn't updated
directly after clicking the button. It _is_ updated after changing the
spin box value - but only if it's a real change, not after changing and
changing back again to the old value. I can't understand this, because
in both cases the same method is called.

I've reduced the problem to a smaller application with a small global
list in place of the database - the offending behaviour stays the same.
But it's still 153 lines of code. Should I post it or is the description

Thanks for hints,

More information about the PyQt mailing list