PyQt6: QComboBox.findData does not work for 'python' objects
Phil Thompson
phil at riverbankcomputing.com
Tue Feb 1 12:36:59 GMT 2022
On 31/01/2022 11:08, Ales Erjavec wrote:
> Hi,
>
> QComboBox.findData does not work for non mapped data types, i.e:
>
> ```
> from PyQt6.QtCore import Qt
> from PyQt6.QtWidgets import QApplication, QComboBox
>
> DataRole = Qt.ItemDataRole.UserRole
>
> A = object()
> B = object()
>
> app = QApplication([])
>
> cb = QComboBox()
> cb.addItem("A")
> cb.addItem("B")
> cb.setItemData(0, A, DataRole)
> cb.setItemData(1, B, DataRole)
> idx = cb.findData(B, DataRole)
> assert idx == 1, f"{idx} == 1"
> ```
> fails the assertion test (idx=-1). It does seem to work for int, str,
> and other
> mapped types.
>
> The same code used to work in PyQt5.
>
> OS: Linux
> Python: 3.10.1
> PyQt6: 6.2.2
Fixed in the next release.
Thanks,
Phil
More information about the PyQt
mailing list