'Constrain the pos.'

def constrain(self, pos):

    if self.__constraintFunc:
        return self.__constraintFunc(pos)
    elif (self.__constraint == Qt.Vertical):
        return QPointF(self.pos().x(), pos.y())
    elif (self.__constraint == Qt.Horizontal):
        return QPointF(pos.x(), self.pos().y())
    else:
        return pos
