QListWidgetItem::ItemType broken

Phil Thompson phil at riverbankcomputing.com
Wed Nov 24 11:01:37 GMT 2021


On 24/11/2021 08:02, Kovid Goyal wrote:
> python -c 'from PyQt6.QtWidgets import *; l = QListWidgetItem(None,
> QListWidgetItem.ItemType.UserType)'       
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> TypeError: arguments did not match any overloaded call:
>   QListWidgetItem(parent: QListWidget = None, type: int =
> QListWidgetItem.Type): argument 2 has unexpected type 'ItemType'
>   QListWidgetItem(str, parent: QListWidget = None, type: int =
> QListWidgetItem.Type): argument 2 has unexpected type 'ItemType'
>   QListWidgetItem(QIcon, str, parent: QListWidget = None, type: int =
> QListWidgetItem.Type): argument 1 has unexpected type 'NoneType'
>   QListWidgetItem(QListWidgetItem): argument 1 has unexpected type 
> 'NoneType'
> 
> 
> This is because in Qt the type argument is an int not an enum. So this
> is technically not a bug in PyQt6. However, its extremely un-intuitive.
> Maybe make OListWidgetItem.ItemType an IntEnum and have
> QListWidgetItemType::type() also return the intenum not an int.

Any enum that has a member that corresponds to some user extendable base 
value should be an IntEnum.

Fixed in the next snapshot - although I haven't changed the type 
returned by type().

Thanks,
Phil


More information about the PyQt mailing list