Q:

How to set the background QBrush of a QMdiArea widget to a gradient of system colors?

I'm trying to set the background QBrush of a QMdiArea widget in Qt4 to a gradient of system colors.
Here's some code I have now:
QPrios::QPrios(int &argc, char **argv): QApplication(argc, argv)
{
        // ... 
        QPalette pal = this->palette();
        QLinearGradient grad;
        grad.setColorAt(0, pal.text().color());
        grad.setColorAt(1, pal.window().color());
        _mdi->setBackground(QBrush(grad));
        // ...
}

What happens is that the background becomes just a solid color, the one set with grad.setColorAt(1, pal.window().color());
What am I doing wrong?

A:

Set the gradient's coordinate mode. You might also want to set the gradient's start and stop points at constructor if you want a vertical gradient.
QLinearGradient grad(QPointF(0, 0), QPointF(0, 1));
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
grad.setColorAt(0, pal.text().color());
grad.setColorAt(1, pal.window().color());

