def css_gradient(gradient):
    """
    Given an instance of a `QLinearGradient` return an equivalent qt css
    gradient fragment.

    """
    stop, finalStop = gradient.start(), gradient.finalStop()
    x1, y1, x2, y2 = stop.x(), stop.y(), finalStop.x(), finalStop.y()
    stops = gradient.stops()
    stops = "\n".join(
        "    stop: {0:f} {1}".format(stop, color.name()) for stop, color in stops
    )
    return (
        "qlineargradient(\n" "    x1: {x1}, y1: {y1}, x2: {x1}, y2: {y2},\n" "{stops})"
    ).format(x1=x1, y1=y1, x2=x2, y2=y2, stops=stops)