QGradient

PyQt5.QtGui.QGradient

Inherited by QConicalGradient, QLinearGradient, QRadialGradient.

Description

The QGradient class is used in combination with QBrush to specify gradient fills.

Qt currently supports three types of gradient fills:

  • Linear gradients interpolate colors between start and end points.

  • Simple radial gradients interpolate colors between a focal point and end points on a circle surrounding it.

  • Extended radial gradients interpolate colors between a center and a focal circle.

  • Conical gradients interpolate colors around a center point.

A gradient鈥檚 type can be retrieved using the type() function. Each of the types is represented by a subclass of QGradient:

QLinearGradient

QRadialGradient

QConicalGradient

image-qgradient-linear-png

image-qgradient-radial-png

image-qgradient-conical-png

The colors in a gradient are defined using stop points of the QGradientStop type; i.e., a position and a color. Use the setColorAt() function to define a single stop point. Alternatively, use the setStops() function to define several stop points in one go. Note that the latter function replaces the current set of stop points.

It is the gradient鈥檚 complete set of stop points (accessible through the stops() function) that describes how the gradient area should be filled. If no stop points have been specified, a gradient of black at 0 to white at 1 is used.

A diagonal linear gradient from black at (100, 100) to white at (200, 200) could be specified like this:

#     QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
#     linearGrad.setColorAt(0, Qt::black);
#     linearGrad.setColorAt(1, Qt::white);

A gradient can have an arbitrary number of stop points. The following would create a radial gradient starting with red in the center, blue and then green on the edges:

#     QRadialGradient radialGrad(QPointF(100, 100), 100);
#     radialGrad.setColorAt(0, Qt::red);
#     radialGrad.setColorAt(0.5, Qt::blue);
#     radialGrad.setColorAt(1, Qt::green);

It is possible to repeat or reflect the gradient outside its area by specifiying the Spread using the setSpread() function. The default is to pad the outside area with the color at the closest stop point. The currently set Spread can be retrieved using the spread() function. The Spread enum defines three different methods:

image-qradialgradient-pad-png

image-qradialgradient-repeat-png

image-qradialgradient-reflect-png

PadSpread

RepeatSpread

ReflectSpread

Note that the setSpread() function only has effect for linear and radial gradients. The reason is that the conical gradient is closed by definition, i.e. the conical gradient fills the entire circle from 0 - 360 degrees, while the boundary of a radial or a linear gradient can be specified through its radius or final stop points, respectively.

The gradient coordinates can be specified in logical coordinates, relative to device coordinates, or relative to object bounding box coordinates. The CoordinateMode can be set using the setCoordinateMode() function. The default is LogicalMode, where the gradient coordinates are specified in the same way as the object coordinates. To retrieve the currently set CoordinateMode use coordinateMode().

Enums

CoordinateMode

This enum specifies how gradient coordinates map to the paint device on which the gradient is used.

Member

Value

Description

LogicalMode

0

This is the default mode. The gradient coordinates are specified logical space just like the object coordinates.

ObjectBoundingMode

2

This mode is the same as ObjectMode, except that the {transform()} {brush transform}, if any, is applied relative to the logical space instead of the object space. This enum value is deprecated and should not be used in new code.

ObjectMode

TODO

In this mode the gradient coordinates are relative to the bounding rectangle of the object being drawn, with (0,0) in the top left corner, and (1,1) in the bottom right corner of the object鈥檚 bounding rectangle. This value was added in Qt 5.12.

StretchToDeviceMode

1

In this mode the gradient coordinates are relative to the bounding rectangle of the paint device, with (0,0) in the top left corner, and (1,1) in the bottom right corner of the paint device.


Preset

TODO

Member

Value

Description

AboveTheSky

TODO

TODO

AfricanField

TODO

TODO

AlchemistLab

TODO

TODO

AmourAmour

TODO

TODO

AmyCrisp

TODO

TODO

AngelCare

TODO

TODO

AquaGuidance

TODO

TODO

AquaSplash

TODO

TODO

AwesomePine

TODO

TODO

BigMango

TODO

TODO

BlackSea

TODO

TODO

Blessing

TODO

TODO

BurningSpring

TODO

TODO

CheerfulCaramel

TODO

TODO

ChildCare

TODO

TODO

CleanMirror

TODO

TODO

CloudyApple

TODO

TODO

CloudyKnoxville

TODO

TODO

CochitiLake

TODO

TODO

ColdEvening

TODO

TODO

ColorfulPeach

TODO

TODO

ConfidentCloud

TODO

TODO

Crystalline

TODO

TODO

CrystalRiver

TODO

TODO

DeepBlue

TODO

TODO

DeepRelief

TODO

TODO

DenseWater

TODO

TODO

DesertHump

TODO

TODO

DirtyBeauty

TODO

TODO

DustyGrass

TODO

TODO

EternalConstance

TODO

TODO

EverlastingSky

TODO

TODO

FabledSunset

TODO

TODO

FarawayRiver

TODO

TODO

FebruaryInk

TODO

TODO

FlyHigh

TODO

TODO

FlyingLemon

TODO

TODO

ForestInei

TODO

TODO

FreshMilk

TODO

TODO

FreshOasis

TODO

TODO

FrozenBerry

TODO

TODO

FrozenDreams

TODO

TODO

FrozenHeat

TODO

TODO

FruitBlend

TODO

TODO

GagarinView

TODO

TODO

GentleCare

TODO

TODO

GlassWater

TODO

TODO

GrassShampoo

TODO

TODO

GreatWhale

TODO

TODO

GrownEarly

TODO

TODO

HappyAcid

TODO

TODO

HappyFisher

TODO

TODO

HappyMemories

TODO

TODO

HappyUnicorn

TODO

TODO

HealthyWater

TODO

TODO

HeavenPeach

TODO

TODO

HeavyRain

TODO

TODO

HiddenJaguar

TODO

TODO

HighFlight

TODO

TODO

ItmeoBranding

TODO

TODO

JapanBlush

TODO

TODO

JuicyCake

TODO

TODO

JuicyPeach

TODO

TODO

JungleDay

TODO

TODO

KindSteel

TODO

TODO

LadogaBottom

TODO

TODO

LadyLips

TODO

TODO

LandingAircraft

TODO

TODO

LeCocktail

TODO

TODO

LemonGate

TODO

TODO

LightBlue

TODO

TODO

LilyMeadow

TODO

TODO

LoveKiss

TODO

TODO

MagicLake

TODO

TODO

MagicRay

TODO

TODO

MalibuBeach

TODO

TODO

MarbleWall

TODO

TODO

MarsParty

TODO

TODO

MeanFruit

TODO

TODO

MidnightBloom

TODO

TODO

MillenniumPine

TODO

TODO

MindCrawl

TODO

TODO

MixedHopes

TODO

TODO

MoleHall

TODO

TODO

MorningSalad

TODO

TODO

MorpheusDen

TODO

TODO

MountainRock

TODO

TODO

NearMoon

TODO

TODO

Nega

TODO

TODO

NewLife

TODO

TODO

NewRetrowave

TODO

TODO

NewYork

TODO

TODO

NightCall

TODO

TODO

NightFade

TODO

TODO

NightParty

TODO

TODO

NightSky

TODO

TODO

NorseBeauty

TODO

TODO

NorthMiracle

TODO

TODO

NumPresets

TODO

TODO

OctoberSilence

TODO

TODO

OldHat

TODO

TODO

OrangeJuice

TODO

TODO

OverSun

TODO

TODO

PaloAlto

TODO

TODO

PartyBliss

TODO

TODO

PassionateBed

TODO

TODO

PerfectBlue

TODO

TODO

PerfectWhite

TODO

TODO

PhoenixStart

TODO

TODO

PlumBath

TODO

TODO

PlumPlate

TODO

TODO

PoliteRumors

TODO

TODO

PremiumDark

TODO

TODO

PremiumWhite

TODO

TODO

PurpleDivision

TODO

TODO

RainyAshville

TODO

TODO

RareWind

TODO

TODO

RedSalvation

TODO

TODO

RichMetal

TODO

TODO

RipeMalinka

TODO

TODO

RiskyConcrete

TODO

TODO

RiverCity

TODO

TODO

RoyalGarden

TODO

TODO

SaintPetersburg

TODO

TODO

SaltMountain

TODO

TODO

SandStrike

TODO

TODO

SeaLord

TODO

TODO

Seashore

TODO

TODO

SeaStrike

TODO

TODO

ShadyWater

TODO

TODO

SharpBlues

TODO

TODO

SharpeyeEagle

TODO

TODO

ShyRainbow

TODO

TODO

SkyGlider

TODO

TODO

SleeplessNight

TODO

TODO

SmartIndigo

TODO

TODO

SmilingRain

TODO

TODO

SnowAgain

TODO

TODO

SoftCherish

TODO

TODO

SoftGrass

TODO

TODO

SoftLipstick

TODO

TODO

SolidStone

TODO

TODO

SpaceShift

TODO

TODO

SpikyNaga

TODO

TODO

SpringWarmth

TODO

TODO

StarWine

TODO

TODO

StrictNovember

TODO

TODO

StrongBliss

TODO

TODO

StrongStick

TODO

TODO

SugarLollipop

TODO

TODO

SummerGames

TODO

TODO

SunnyMorning

TODO

TODO

SunVeggie

TODO

TODO

SupremeSky

TODO

TODO

SweetDessert

TODO

TODO

SweetPeriod

TODO

TODO

TeenNotebook

TODO

TODO

TeenParty

TODO

TODO

TemptingAzure

TODO

TODO

TrueSunset

TODO

TODO

ViciousStance

TODO

TODO

WarmFlame

TODO

TODO

WideMatrix

TODO

TODO

WildApple

TODO

TODO

WinterNeva

TODO

TODO

WitchDance

TODO

TODO

YoungGrass

TODO

TODO

YoungPassion

TODO

TODO

ZeusMiracle

TODO

TODO


Spread

Specifies how the area outside the gradient area should be filled.

See also

spread(), setSpread().

Member

Value

Description

PadSpread

0

The area is filled with the closest stop color. This is the default.

ReflectSpread

1

The gradient is reflected outside the gradient area.

RepeatSpread

2

The gradient is repeated outside the gradient area.


Type

Specifies the type of gradient.

See also

type().

Member

Value

Description

ConicalGradient

2

Interpolate colors around a center point (QConicalGradient).

LinearGradient

0

Interpolates colors between start and end points (QLinearGradient).

NoGradient

3

No gradient is used.

RadialGradient

1

Interpolate colors between a focal point and end points on a circle surrounding it (QRadialGradient).

Methods

__init__()

TODO


__init__(Preset)

TODO


__init__(QGradient)

TODO


coordinateMode() → CoordinateMode

Returns the coordinate mode of this gradient. The default mode is LogicalMode.


__eq__(QGradient) → bool

TODO


__ne__(QGradient) → bool

TODO


setColorAt(float, Union[QColor, GlobalColor, QGradient])

TODO


setCoordinateMode(CoordinateMode)

See also

coordinateMode().


setSpread(Spread)

See also

spread().


setStops(Iterable[Tuple[float, Union[QColor, GlobalColor, QGradient]]])

See also

stops().


spread() → Spread

See also

setSpread().


stops() → List[Tuple[float, QColor]]

Returns the stop points for this gradient.

If no stop points have been specified, a gradient of black at 0 to white at 1 is used.


type() → Type

TODO