QListWidgetItem::ItemType broken
Kovid Goyal
kovid at kovidgoyal.net
Wed Nov 24 08:02:04 GMT 2021
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.
--
_____________________________________
Dr. Kovid Goyal
https://www.kovidgoyal.net
https://calibre-ebook.com
_____________________________________
More information about the PyQt
mailing list