[PyKDE] Small database application - best way?

Sibylle Koczian Sibylle.Koczian at T-Online.de
Tue Nov 28 11:10:00 GMT 2006


"Matt Newell" <newellm at blur.com> schrieb:
> On Monday 27 November 2006 00:50, Sibylle Koczian wrote:
> snipped...
> > Double clicking, pressing F2 or Enter in a cell in one of the editable
> > columns doesn't select the text of this cell, as it does in the example
> > programs with editable models. Instead it erases the text completely. Not
> > helpful, if a small typo should be corrected, a date altered by one day or
> > similar small changes are necessary.
> >
> Sounds like you aren't handling Qt::EditRole in you model's data function, it 
> should be returning the same thing as Qt::DisplayRole.
> 

Yes, that solved this problem, thank you. Two other things still don't work:

Moving with the tab key through the table cells only works after the first change.

And, more important: in the setData method the dataChanged signal is emitted:

def setData(self, index, value, role):
...
    self.emit(QtCore.SIGNAL('dataChanged'), index, index)
    return True

and in the __init__ method of the main window this is connected to a method of this window:

self.connect(self.model, QtCore.SIGNAL('dataChanged(const QModelIndex &, const QModelIndex &)'),
             self.ausgeben)

But this doesn't work, self.ausgeben (which prints a message to stdin) isn't called.

What's wrong here?

I didn't find an example for an editable model subclassed from QAbstractTableModel. Did I overlook it?

Thank you,
Sibylle

-- 
Dr. Sibylle Koczian 
Fasanenstrasse 12 
D-82293 Mittelstetten 




More information about the PyQt mailing list