[PyQt] [PyQt5 BUG] the 3rd parameter of QAbstractItemModel::dataChanged() is optional
    Phil Thompson 
    phil at riverbankcomputing.com
       
    Sat Dec 21 15:47:18 GMT 2013
    
    
  
On 20-12-2013 4:46 am, iMath wrote:
> when I run the code here
> http://codepad.org/ubtleeFG
> the following error happened
>
>>>>
> Traceback (most recent call last):
>  File "E:g.py", line 22, in timerHit
>  self.dataChanged.emit (topLeft, topLeft);
> TypeError: QAbstractItemModel.dataChanged[QModelIndex, QModelIndex,
> list-of-int] signal has 3 argument(s) but 2 provided
>
> the cause is that the 3rd parameter of
>
> VOID QABSTRACTITEMMODEL::DATACHANGED(CONST QMODELINDEX &_ TOPLEFT_,
> CONST QMODELINDEX &_ BOTTOMRIGHT_, CONST QVECTOR<INT> &_ ROLES_ =
> QVECTOR<INT> ()) [SIGNAL]
>
>  is optional,while in PyQt5 it seems not .
Qt implements signals with default arguments as multiple signals with 
fixed arguments. The overload with the largest number of arguments is 
the default one as far as PyQt is concerned - the one with 3 arguments 
in this case.
Therefore you must specify the 3rd argument...
     self.dataChanged.emit(topLeft, topLeft, [])
...or specify the overload with 2 arguments...
     self.dataChanged[QModelIndex, QModelIndex].emit(topLeft, topLeft)
Tonight's snapshot makes emit() a bit smarter so that your current...
     self.dataChanged(topLeft, topLeft)
...will work.
Phil
    
    
More information about the PyQt
mailing list