[PyQt] 回复: 回复: [PyQt5 BUG] the 3rd parameter ofQAbstractItemModel::dataChanged() is optional

iMath 2281570025 at qq.com
Thu Jan 9 07:22:36 GMT 2014


when you run the code here
http://codepad.org/ubtleeFG
the error I mentioned last time disappeared ,but this program still doesn't work.
  
 tested on PyQt5-5.2-gpl-Py3.3-Qt5.2.0-x32  ,WinXp
  

 ------------------ 原始邮件 ------------------
  发件人: "phil";<phil at riverbankcomputing.com>;
 发送时间: 2013年12月24日(星期二) 上午6:28
 收件人: "iMath"<2281570025 at qq.com>; 
 
 主题: Re: 回复: [PyQt5 BUG] the 3rd parameter ofQAbstractItemModel::dataChanged() is optional

 

On 23-12-2013 1:05 pm, iMath wrote:
> “Qt implements signals with default arguments as multiple signals
> with
>  fixed arguments. The overload with the largest number of arguments 
> is
>
>  the default one.”
>
> you know this from where ?

For the first sentence, by looking at the Qt source code.

For the second sentence, because that's the way I wrote it.

> BTW ,self.dataChanged(topLeft, topLeft) works well(without modified)
> in PyQt4 J

...because the signature in Qt4 is different to the signature in Qt5.

Phil

> ------------------ 原始邮件 ------------------
>
> 发件人: "phil";<phil at riverbankcomputing.com>;
> 发送时间: 2013年12月21日(星期六) 晚上11:47
> 收件人: "iMath"<2281570025 at qq.com>;
> 抄送: "pyqt"<pyqt at riverbankcomputing.com>;
> 主题: Re: [PyQt5 BUG] the 3rd parameter
> ofQAbstractItemModel::dataChanged() is optional
>
> 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
> .

.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140109/e2e748f9/attachment.html>


More information about the PyQt mailing list