Menu

QByteArrayList is not iterable

Help
2017-05-23
2017-05-23
  • David Brooks

    David Brooks - 2017-05-23

    What would be needed to make QByteArrayList objects iterable? As the following example shows they cannot currently be iterated over.

    >>> from PythonQt import QtGui
    >>> fmts = QtGui.QImageReader.supportedImageFormats()
    >>> type(fmts)
    <class 'PythonQt.private.QByteArrayList'>
    >>> fmts[0]
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    TypeError: 'QByteArrayList' object does not support indexing
    >>> iter(fmts)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    TypeError: 'QByteArrayList' object is not iterable
    
     
  • Florian Link

    Florian Link - 2017-05-23

    I fixed this on the SVN trunk. It now returns a tuple containing QByteArray. To convert a QByteArray to Python str, use str(array).

     

Log in to post a comment.