QGradient Class▲
-
Header: QGradient
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
-
qmake: QT += gui
-
Inherited By: https://, https://, and https://
-
Group: QGradient is part of https://, shared
Detailed Description▲
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's type can be retrieved using the https://() function. Each of the types is represented by a subclass of https://:
|
https:// |
https:// |
https:// |
|---|---|---|
|
|
|
|
The colors in a gradient are defined using stop points of the https:// type; i.e., a position and a color. Use the https://() function to define a single stop point. Alternatively, use the https://() 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's complete set of stop points (accessible through the https://() 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 specifying the https:// using the https://() function. The default is to pad the outside area with the color at the closest stop point. The currently set https:// can be retrieved using the https://() function. The https:// enum defines three different methods:
|
|
|
|
|
https:// |
https:// |
https:// |
Note that the https://() 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 https:// can be set using the https://() function. The default is https://, where the gradient coordinates are specified in the same way as the object coordinates. To retrieve the currently set https:// use https://().
See Also▲
See also https://, QBrush
Member Type Documentation▲
enum QGradient::CoordinateMode▲
This enum specifies how gradient coordinates map to the paint device on which the gradient is used.
|
Constant |
Value |
Description |
|---|---|---|
|
https://::LogicalMode |
0 |
This is the default mode. The gradient coordinates are specified logical space just like the object coordinates. |
|
https://::ObjectMode |
3 |
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's bounding rectangle. This value was added in Qt 5.12. |
|
https://::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. |
|
https://::ObjectBoundingMode |
2 |
This mode is the same as ObjectMode, except that the {https://()} {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. |
[since 5.12] enum QGradient::Preset▲
This enum specifies a set of predefined presets for https://, based on the gradients from https://.
|
Constant |
|
|---|---|
|
https://::WarmFlame |
1 |
|
https://::NightFade |
2 |
|
https://::SpringWarmth |
3 |
|
https://::JuicyPeach |
4 |
|
https://::YoungPassion |
5 |
|
https://::LadyLips |
6 |
|
https://::SunnyMorning |
7 |
|
https://::RainyAshville |
8 |
|
https://::FrozenDreams |
9 |
|
https://::WinterNeva |
10 |
|
https://::DustyGrass |
11 |
|
https://::TemptingAzure |
12 |
|
https://::HeavyRain |
13 |
|
https://::AmyCrisp |
14 |
|
https://::MeanFruit |
15 |
|
https://::DeepBlue |
16 |
|
https://::RipeMalinka |
17 |
|
https://::CloudyKnoxville |
18 |
|
https://::MalibuBeach |
19 |
|
https://::NewLife |
20 |
|
https://::TrueSunset |
21 |
|
https://::MorpheusDen |
22 |
|
https://::RareWind |
23 |
|
https://::NearMoon |
24 |
|
https://::WildApple |
25 |
|
https://::SaintPetersburg |
26 |
|
https://::PlumPlate |
28 |
|
https://::EverlastingSky |
29 |
|
https://::HappyFisher |
30 |
|
https://::Blessing |
31 |
|
https://::SharpeyeEagle |
32 |
|
https://::LadogaBottom |
33 |
|
https://::LemonGate |
34 |
|
https://::ItmeoBranding |
35 |
|
https://::ZeusMiracle |
36 |
|
https://::OldHat |
37 |
|
https://::StarWine |
38 |
|
https://::HappyAcid |
41 |
|
https://::AwesomePine |
42 |
|
https://::NewYork |
43 |
|
https://::ShyRainbow |
44 |
|
https://::MixedHopes |
46 |
|
https://::FlyHigh |
47 |
|
https://::StrongBliss |
48 |
|
https://::FreshMilk |
49 |
|
https://::SnowAgain |
50 |
|
https://::FebruaryInk |
51 |
|
https://::KindSteel |
52 |
|
https://::SoftGrass |
53 |
|
https://::GrownEarly |
54 |
|
https://::SharpBlues |
55 |
|
https://::ShadyWater |
56 |
|
https://::DirtyBeauty |
57 |
|
https://::GreatWhale |
58 |
|
https://::TeenNotebook |
59 |
|
https://::PoliteRumors |
60 |
|
https://::SweetPeriod |
61 |
|
https://::WideMatrix |
62 |
|
https://::SoftCherish |
63 |
|
https://::RedSalvation |
64 |
|
https://::BurningSpring |
65 |
|
https://::NightParty |
66 |
|
https://::SkyGlider |
67 |
|
https://::HeavenPeach |
68 |
|
https://::PurpleDivision |
69 |
|
https://::AquaSplash |
70 |
|
https://::SpikyNaga |
72 |
|
https://::LoveKiss |
73 |
|
https://::CleanMirror |
75 |
|
https://::PremiumDark |
76 |
|
https://::ColdEvening |
77 |
|
https://::CochitiLake |
78 |
|
https://::SummerGames |
79 |
|
https://::PassionateBed |
80 |
|
https://::MountainRock |
81 |
|
https://::DesertHump |
82 |
|
https://::JungleDay |
83 |
|
https://::PhoenixStart |
84 |
|
https://::OctoberSilence |
85 |
|
https://::FarawayRiver |
86 |
|
https://::AlchemistLab |
87 |
|
https://::OverSun |
88 |
|
https://::PremiumWhite |
89 |
|
https://::MarsParty |
90 |
|
https://::EternalConstance |
91 |
|
https://::JapanBlush |
92 |
|
https://::SmilingRain |
93 |
|
https://::CloudyApple |
94 |
|
https://::BigMango |
95 |
|
https://::HealthyWater |
96 |
|
https://::AmourAmour |
97 |
|
https://::RiskyConcrete |
98 |
|
https://::StrongStick |
99 |
|
https://::ViciousStance |
100 |
|
https://::PaloAlto |
101 |
|
https://::HappyMemories |
102 |
|
https://::MidnightBloom |
103 |
|
https://::Crystalline |
104 |
|
https://::PartyBliss |
106 |
|
https://::ConfidentCloud |
107 |
|
https://::LeCocktail |
108 |
|
https://::RiverCity |
109 |
|
https://::FrozenBerry |
110 |
|
https://::ChildCare |
112 |
|
https://::FlyingLemon |
113 |
|
https://::NewRetrowave |
114 |
|
https://::HiddenJaguar |
115 |
|
https://::AboveTheSky |
116 |
|
https://::Nega |
117 |
|
https://::DenseWater |
118 |
|
https://::Seashore |
120 |
|
https://::MarbleWall |
121 |
|
https://::CheerfulCaramel |
122 |
|
https://::NightSky |
123 |
|
https://::MagicLake |
124 |
|
https://::YoungGrass |
125 |
|
https://::ColorfulPeach |
126 |
|
https://::GentleCare |
127 |
|
https://::PlumBath |
128 |
|
https://::HappyUnicorn |
129 |
|
https://::AfricanField |
131 |
|
https://::SolidStone |
132 |
|
https://::OrangeJuice |
133 |
|
https://::GlassWater |
134 |
|
https://::NorthMiracle |
136 |
|
https://::FruitBlend |
137 |
|
https://::MillenniumPine |
138 |
|
https://::HighFlight |
139 |
|
https://::MoleHall |
140 |
|
https://::SpaceShift |
142 |
|
https://::ForestInei |
143 |
|
https://::RoyalGarden |
144 |
|
https://::RichMetal |
145 |
|
https://::JuicyCake |
146 |
|
https://::SmartIndigo |
147 |
|
https://::SandStrike |
148 |
|
https://::NorseBeauty |
149 |
|
https://::AquaGuidance |
150 |
|
https://::SunVeggie |
151 |
|
https://::SeaLord |
152 |
|
https://::BlackSea |
153 |
|
https://::GrassShampoo |
154 |
|
https://::LandingAircraft |
155 |
|
https://::WitchDance |
156 |
|
https://::SleeplessNight |
157 |
|
https://::AngelCare |
158 |
|
https://::CrystalRiver |
159 |
|
https://::SoftLipstick |
160 |
|
https://::SaltMountain |
161 |
|
https://::PerfectWhite |
162 |
|
https://::FreshOasis |
163 |
|
https://::StrictNovember |
164 |
|
https://::MorningSalad |
165 |
|
https://::DeepRelief |
166 |
|
https://::SeaStrike |
167 |
|
https://::NightCall |
168 |
|
https://::SupremeSky |
169 |
|
https://::LightBlue |
170 |
|
https://::MindCrawl |
171 |
|
https://::LilyMeadow |
172 |
|
https://::SugarLollipop |
173 |
|
https://::SweetDessert |
174 |
|
https://::MagicRay |
175 |
|
https://::TeenParty |
176 |
|
https://::FrozenHeat |
177 |
|
https://::GagarinView |
178 |
|
https://::FabledSunset |
179 |
|
https://::PerfectBlue |
180 |
This enum was introduced or modified in Qt 5.12.
enum QGradient::Spread▲
Specifies how the area outside the gradient area should be filled.
|
Constant |
Value |
Description |
|---|---|---|
|
https://::PadSpread |
0 |
The area is filled with the closest stop color. This is the default. |
|
https://::RepeatSpread |
2 |
The gradient is repeated outside the gradient area. |
|
https://::ReflectSpread |
1 |
The gradient is reflected outside the gradient area. |
See Also▲
See also https://(), https://()
enum QGradient::Type▲
Specifies the type of gradient.
|
Constant |
Value |
Description |
|---|---|---|
|
https://::LinearGradient |
0 |
Interpolates colors between start and end points (https://). |
|
https://::RadialGradient |
1 |
Interpolate colors between a focal point and end points on a circle surrounding it (https://). |
|
https://::ConicalGradient |
2 |
Interpolate colors around a center point (https://). |
|
https://::NoGradient |
3 |
No gradient is used. |
See Also▲
See also https://()
Member Function Documentation▲
[since 5.12] QGradient::QGradient(QGradient::Preset preset)▲
Constructs a gradient based on a predefined preset.
The coordinate mode of the resulting gradient is https://, allowing the preset to be applied to arbitrary object sizes.
This function was introduced in Qt 5.12.
QGradient::CoordinateMode QGradient::coordinateMode() const▲
Returns the coordinate mode of this gradient. The default mode is https://.
See Also▲
See also https://()
void QGradient::setColorAt(qreal position, const QColor &color)▲
Creates a stop point at the given position with the given color. The given position must be in the range 0 to 1.
See Also▲
See also https://(), https://()
void QGradient::setCoordinateMode(QGradient::CoordinateMode mode)▲
Sets the coordinate mode of this gradient to mode. The default mode is https://.
See Also▲
See also https://()
void QGradient::setSpread(QGradient::Spread method)▲
Specifies the spread method that should be used for this gradient.
Note that this function only has effect for linear and radial gradients.
See Also▲
See also https://()
void QGradient::setStops(const QGradientStops &stopPoints)▲
Replaces the current set of stop points with the given stopPoints. The positions of the points must be in the range 0 to 1, and must be sorted with the lowest point first.
See Also▲
See also https://(), https://()
QGradient::Spread QGradient::spread() const▲
Returns the spread method use by this gradient. The default is https://.
See Also▲
See also https://()
QGradientStops QGradient::stops() const▲
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.
See Also▲
See also https://(), https://()
QGradient::Type QGradient::type() const▲
Returns the type of gradient.
bool QGradient::operator!=(const QGradient &gradient) const▲
Returns true if the gradient is the same as the other gradient specified; otherwise returns false.
See Also▲
See also https://()
bool QGradient::operator==(const QGradient &gradient) const▲
Returns true if the gradient is the same as the other gradient specified; otherwise returns false.
See Also▲
See also https://()


