在派生类中重载QDialog的void paintEvent(QPaintEvent *)事件,在这个函数中加入以下代码
QPainter painter(this);
QLinearGradient grad(0, 0, width(), height());
QGradientStops gs;
gs << QGradientStop(0.0, QColor(0, 0, 0 , 100))
<< QGradientStop(0.5, QColor(0, 0, 0, 100))
<< QGradientStop(1.0, QColor(0, 0, 0, 100));
grad.setStops(gs);
painter.fillRect(0, 0, width(), height(), grad);
http://blog.csdn.net/itjobtxq/article/details/8766721
时间: 2024-10-13 16:08:03