QCanvasBoxGradient Class
QCanvasBoxGradient ist ein Pinsel für das Malen von Box-Gradienten. Mehr...
| Kopfzeile: | #include <QCanvasBoxGradient> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter) |
| Seit: | Qt 6.11 |
| Erbt: | QCanvasGradient |
| Status: | Technische Vorschau |
Öffentliche Funktionen
| QCanvasBoxGradient() | |
| QCanvasBoxGradient(const QRectF &rect, float feather, float radius = 0.0f) | |
| QCanvasBoxGradient(float x, float y, float width, float height, float feather, float radius = 0.0f) | |
| float | feather() const |
| float | radius() const |
| QRectF | rect() const |
| void | setFeather(float feather) |
| void | setRadius(float radius) |
| void | setRect(float x, float y, float width, float height) |
| void | setRect(const QRectF &rect) |
Detaillierte Beschreibung
Box-Gradient interpoliert Farben zwischen Start- und Endpunkt und erzeugt so einen abgerundeten, rechteckigen Farbverlauf. Mit den Funktionen setRadius() und setFeather() kann die Rundheit und Weichheit des Farbverlaufs gesteuert werden.

Hier ist ein einfaches Beispiel:
![]() | QRectF rect(20, 20, 160, 160); QCanvasBoxGradient bg(rect, 20, 50); bg.setColorAt(0.0, "#1a2a6c"); bg.setColorAt(0.2, "#fdbb2d"); bg.setColorAt(1.0, QColorConstants::Transparent); p->setFillStyle(bg); p->fillRect(rect); |
Hinweis: Wenn QCanvasBoxGradient verwendet wird, um ein rundes Rechteck zu malen, ist es in der Regel besser, QCanvasPainter::rect() als QCanvasPainter::roundRect() zu verwenden, da die Abrundung durch den Pinsel und nicht durch den Pfad erfolgt. Dies vermeidet die Erstellung zusätzlicher Scheitelpunkte und führt daher zu besseren Ergebnissen.
Dokumentation der Mitgliedsfunktionen
QCanvasBoxGradient::QCanvasBoxGradient()
Konstruiert einen Standard-Box-Gradienten. Die Position des Farbverlaufs ist (0, 0) und die Größe (100, 100) Der Farbverlauf ist 10.0. Der Radius des Farbverlaufs ist 0,0. Die Startfarbe des Farbverlaufs ist weiß (255, 255, 255) und die Endfarbe transparent schwarz (0, 0, 0, 0).
QCanvasBoxGradient::QCanvasBoxGradient(const QRectF &rect, float feather, float radius = 0.0f)
Konstruiert einen Box-Gradienten. Position und Größe des Farbverlaufs sind rect. Die Feder des Farbverlaufs ist feather. Der Radius des Farbverlaufs ist radius. Die Startfarbe des Farbverlaufs ist weiß (255, 255, 255) und die Endfarbe transparent schwarz (0, 0, 0, 0).
QCanvasBoxGradient::QCanvasBoxGradient(float x, float y, float width, float height, float feather, float radius = 0.0f)
Konstruiert einen Box-Farbverlauf. Die Position des Farbverlaufs ist ( x, y) und die Größe ( width, height) Die Feder des Farbverlaufs ist feather. Der Radius des Farbverlaufs ist radius. Die Startfarbe des Farbverlaufs ist weiß (255, 255, 255) und die Endfarbe transparent schwarz (0, 0, 0, 0).
float QCanvasBoxGradient::feather() const
Gibt die Feder des Box-Farbverlaufs zurück.
Siehe auch setFeather().
float QCanvasBoxGradient::radius() const
Gibt den Radius des Box-Gradienten zurück.
Siehe auch setRadius().
QRectF QCanvasBoxGradient::rect() const
Gibt die Rechteckfläche des Box-Farbverlaufs zurück.
Siehe auch setRect().
void QCanvasBoxGradient::setFeather(float feather)
Setzt die Feder des Box-Farbverlaufs auf feather.
Siehe auch feather().
void QCanvasBoxGradient::setRadius(float radius)
Setzt den Radius des Box-Gradienten auf radius. Der maximale Radius ist die Hälfte der Breite oder Höhe von rect(), je nachdem, welcher Wert kleiner ist.
Siehe auch radius().
void QCanvasBoxGradient::setRect(float x, float y, float width, float height)
Setzt das Rechteck des Box-Farbverlaufs auf Position ( x, y) und Größe ( width, height).
Siehe auch rect().
void QCanvasBoxGradient::setRect(const QRectF &rect)
Setzt das Rechteck des Box-Farbverlaufs auf rect.
Dies ist eine überladene Funktion.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
