Skip to main content

QCustomGradientText

QCustomGradientText

Text filled with a gradient.

The headline treatment every landing page wants and QSS cannot do: Qt stylesheets have no text-fill gradient, so the only route is painting the text with a gradient pen.

Optionally animated, sliding the gradient along the text. The animation is off by default - a permanently shimmering headline is a distraction, and it costs a repaint per frame.

Reuses the multi-stop CSV convention from QCustomGradientPicker, so a gradient authored there drops straight in.

At a glance

TierFree (GPLv3)
Importfrom Custom_Widgets.QCustomGradientText import QCustomGradientText
Qt DesignerYes — drag it from the palette

Quick start

from Custom_Widgets.QCustomGradientText import QCustomGradientText

widget = QCustomGradientText()

Dark theme

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QCustomGradientText in dark theme

Properties

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
textstring
stopsCsvstring0:#2563eb,1:#a855f7
angleint0
animatedboolFalse
animationSpeedint40
fontScalefloat1.6
boldboolTrue
alignmentenum: left/center/right``center
wordWrapboolFalse

Signals

Signal
clicked()

Methods

MethodDescription
alignment(*args, **kwargs)Alignment.
angle(*args, **kwargs)Angle.
animated(*args, **kwargs)Animated.
animationSpeed(*args, **kwargs)Animation speed.
bold(*args, **kwargs)Bold.
clicked(...)Clicked.
fontScale(*args, **kwargs)Font scale.
gradientFor(rect)The gradient across a rect, including the animation offset.
isAnimating()Return whether the widget is animating.
setStops(stops)Replace the gradient stops. Fewer than two is rejected.
start()Start.
stop()Stop.
stops()Stops.
stopsCsv(*args, **kwargs)Stops csv.
text(*args, **kwargs)Text.
wordWrap(*args, **kwargs)Word wrap.

Theming

Colours come from the design tokens, so they follow the active theme. Roles used: accent.

See Design tokens.

Runnable example

A complete app using this widget lives at examples/PySide6/QCustomGradientText/main.py.

AnalogGaugeWidget · QCustomAgendaList · QCustomAlert · QCustomAvatar · QCustomAvatarGroup · QCustomBadge · QCustomCard · QCustomChip