'Read the current buffer pixels out as a QImage.'

def readQImage(self):

    w = self.width()
    h = self.height()
    self.repaint()
    pixels = np.empty((h, w, 4), dtype=np.ubyte)
    pixels[:] = 128
    pixels[..., 0] = 50
    pixels[..., 3] = 255
    glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels)
    tmp = pixels[..., 0].copy()
    pixels[..., 0] = pixels[..., 2]
    pixels[..., 2] = tmp
    pixels = pixels[::(-1)]
    img = fn.makeQImage(pixels, transpose=False)
    return img
