[PyQt] QComboBox.findItem and tuples
Phil Thompson
phil at riverbankcomputing.com
Thu Oct 11 22:26:36 BST 2012
On Thu, 11 Oct 2012 22:21:09 +0200, Vicent Mas <uvemas at gmail.com> wrote:
> Hi,
>
> as shows the following code, QComboBox.findItem works fine with lists
> but no with tuples.
>
> if __name__ == "__main__":
> import sip
> sip.setapi('QVariant', 2)
> from PyQt4 import QtGui
> a = QtGui.QApplication([])
> cb = QtGui.QComboBox()
> cb.addItem("Foo", [3,4])
> cb.addItem("Bah", (2, 2))
> print cb.findData([3,4])
> print cb.findData((2,2))
>
> Is it a bug or just a limitation of the implementation? Or something
else?
>
> TIA
It's a limitation of QVariant in that it doesn't provide an opportunity to
inject a call to a Python comparison function when comparing custom types.
Phil
More information about the PyQt
mailing list