[PyKDE] Strange problem with signal/slot

Andreas Pakulat apaku at gmx.de
Sat Jan 28 21:59:38 GMT 2006

On 28.01.06 23:25:19, Thomas Muders wrote:
> 20060126 version with Qt 4.1.0 under Linux as the 20060127 version
> didn't work.

What exactly doesn't work (I'm asking because it works perfectly here)?

>     def setData(self, idx, value, role):
>  [...]
>         if ok:
>             self.emit(SIGNAL("dataChanged(QModelIndex&,QModelIndex&)"),
> (idx,idx))
>             curExpense.convertedAmount = curExpense.originalAmount * \
>                curExpense.conversionRate
>             cellIndex = self.index(idx.row(), ConvertedAmount, QModelIndex())

Just curious, your ConvertedAmount dictates the column that is used? 

>             self.emit(SIGNAL("dataChanged(QModelIndex&,QModelIndex&)"),
> (cellIndex,cellIndex))
>         return ok
> OK is a bool, which is the required return type for the function. If I
> don't have the emit's, everything is OK. When the emit's are there
> like in the sample, I get the following error on the console:
> TypeError: invalid result type from ExpenseModel.setData()

Hmm, you do know, that you need to emit dataChanged from setData only if
you change an item that is not the one given to you via idx. And your
code does not do that. However I find it strange that you get a

> is this a bug in PyQt or a misunderstanding?

Can't say for sure, can you provide a minimal compilable example? I just
tried to emit that signal in my tablemodel and didn't get any error
(also using a variable for return). 

BTW: The signal signature for dataChanged actually is
dataChanged(const QModelIndex&, const QModelIndex&)
note the const keyword for both parameters.


You will be surrounded by luxury.

More information about the PyQt mailing list