'Adjust the widget geometry to exactly fit the arrow inside
while preserving the arrow path scene geometry.'

def adjustGeometry(self):

    geom = self.geometry().translated((- self.pos()))
    line = self.__line
    arrow_rect = self.__arrowItem.shape().boundingRect()
    if (geom.isNull() and (not line.isNull())):
        geom = QRectF(0, 0, 1, 1)
    if (not geom.contains(arrow_rect)):
        geom = geom.united(arrow_rect)
    geom = geom.intersected(arrow_rect)
    diff = geom.topLeft()
    line = QLineF((line.p1() - diff), (line.p2() - diff))
    geom.translate(self.pos())
    self.setGeometry(geom)
    self.setLine(line)
