[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt6: QComboBox.findData does not work for 'python' objects
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2022-02-01 12:36:59
Message-ID: feb00d6b1081d6d8024e386ba85911d6 () riverbankcomputing ! com
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic