'Return the transform that converts local item coordinates to device coordinates (usually pixels).
Extends deviceTransform to automatically determine the viewportTransform.'

def deviceTransform(self, viewportTransform=None):

    if ((self._exportOpts is not False) and ('painter' in self._exportOpts)):
        return (self._exportOpts['painter'].deviceTransform() * self.sceneTransform())
    if (viewportTransform is None):
        view = self.getViewWidget()
        if (view is None):
            return None
        viewportTransform = view.viewportTransform()
    dt = self._qtBaseClass.deviceTransform(self, viewportTransform)
    if (dt.determinant() == 0):
        return None
    else:
        return dt
