Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-840

PySide2 QPixmap.loadFromData not taking bytes or QBytesArray as documentation states

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • 5.11.3
    • 5.11.2
    • PySide
    • None
    • * PySide2 (5.11.2)
      * Windows 10 Pro
      * Installed using pip
      * Python3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32.
    • Windows

    Description

      When trying to create a QPixmap from data as illustrated in the code below:

       

      curQImage = QPixmap.loadFromData(imgDataBytes) # imgDataBytes type is bytes

       

      I get the following error message:

       

      curQImage = QPixmap.loadFromData(imgDataBytes).scaledToWidth(
      TypeError: descriptor 'loadFromData' requires a 'PySide2.QtGui.QPixmap' object but received a 'bytes'

      This doesn't make any sense, why would a QPixmap.loadFromData expect a PySide2.QtGui.QPixmap instead of bytes or a QByteArray ?

      See Documentation:

      QPixmap Qt 5.11 Documentation

       

      bool loadFromData(const uchar *data, uint len, const char *format = nullptr, Qt::ImageConversionFlags flags = Qt::AutoColor)
      bool loadFromData(const QByteArray &data, const char *format = nullptr, Qt::ImageConversionFlags flags = Qt::AutoColor)

       

      The same code and data works fine with a QImage (which is my workaround for now):

      curQImage = ImageFromData.fromData(imgDataBytes)

       

      Thanks.

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              talonrenaud Renaud Talon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes