Skip to main content

QCustomRainbowButton

QCustomRainbowButton

A button with an animated conic border.

The "shiny" call-to-action: a colour wheel rotating around the rim. QSS cannot animate a gradient, so the border is painted and the rotation driven by a timer.

The animation stops when the widget is hidden. A permanently repainting button on an invisible page is pure battery drain, and it is the kind of thing nobody notices until a laptop fan tells them.

Emits clicked().

At a glance

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

Quick start

from Custom_Widgets.QCustomRainbowButton import QCustomRainbowButton

widget = QCustomRainbowButton()

Dark theme

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

QCustomRainbowButton in dark theme

Properties

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

PropertyTypeDefault
textstringGet started
colorsCsvstring#2563eb,#a855f7,#ec4899,#f59e0b,#16a34a,#2563eb
borderWidthint3
cornerRadiusint10
speedint40
animatedboolTrue
glowboolFalse
filledboolFalse
sizeVariantenum: sm/md/lg``md
textColorcolor#0f172a
surfaceColorcolor#ffffff

Signals

Signal
clicked()

Methods

MethodDescription
animated(*args, **kwargs)Animated.
borderWidth(*args, **kwargs)Border width.
clicked(...)Clicked.
colors()Colors.
colorsCsv(*args, **kwargs)Colors csv.
cornerRadius(*args, **kwargs)Corner radius.
filled(*args, **kwargs)Filled.
glow(*args, **kwargs)Glow.
isAnimating()Return whether the widget is animating.
setColors(colors)Replace the wheel. Fewer than two valid colours is rejected.
sizeVariant(*args, **kwargs)Size variant.
speed(*args, **kwargs)Speed.
start()Start.
stop()Stop.
surfaceColor(*args, **kwargs)Surface color.
text(*args, **kwargs)Text.
textColor(*args, **kwargs)Text color.

Theming

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

See Design tokens.

Runnable example

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

QCustomActionButton · QCustomCopyButton · QCustomQPushButton · QCustomQPushButtonGroup · QCustomSocialButton · QCustomThemeDarkLightToggle · QCustomTileButton