qlineargradient
时间: 2023-11-24 12:03:14 浏览: 109
QLinearGradient is a class in Qt that represents a linear gradient. A linear gradient is a type of gradient that gradually changes color along a straight line.
To use QLinearGradient, you need to create an instance of the class and set its start and end points. You can then add color stops to define the colors at specific points along the gradient line.
Here's an example of how to create a linear gradient that goes from blue to green:
```
QLinearGradient gradient(0, 0, 100, 0); // startX, startY, endX, endY
gradient.setColorAt(0, Qt::blue);
gradient.setColorAt(1, Qt::green);
```
This creates a linear gradient that starts at (0, 0) and ends at (100, 0). The gradient starts with blue at the beginning and gradually transitions to green at the end.
You can use QLinearGradient to fill shapes, draw backgrounds, and create other graphical effects in your Qt applications.
阅读全文