[Matplotlib-devel] Backend for use with Qt/QML

s.achterop at rug.nl s.achterop at rug.nl
Sat Nov 23 07:56:02 EST 2019


On 11/22/19 7:55 PM, Thomas Caswell wrote:

   Thanks Tom for the response.

> The methods are only removed from the c++ classes (which is what you are accessing via `_renderer`) which we consider private and will change with no warning (see https://github.com/matplotlib/matplotlib/pull/11735 for the PR where this was done).  It looks like there are still public methods with 
> the same name on RendererAgg.

Yes, but not the tostring_bgra version. And it seems that matplotlib is in rgba byte order, so it needs this conversion when
the byteorder is little endian as with a regular PC. Or am I mistaken?

My patch, that works on my intel PC, is adding and using the following function

   def tostring_bgra(self):
       return np.asarray(self._renderer).take([2, 1, 0, 3], axis=2).tobytes()

To RendererAgg.
Maybe add this function to RendererAgg?

> 
>  Is there a reason you can not directly use the QWidget sub-class we provide ?

Well, this is what the code I forked from did.
I think the reason is that to embed in a Qt/QML program and being able to paint directly on the canvas we need to subclass QtQuick.QQuickPaintedItem.
See
   https://doc.qt.io/qt-5/qtqml-tutorials-extending-qml-example.html

QML is quite different than traditional Qt.

    Thanks again,
        Sietse


More information about the Matplotlib-devel mailing list