Hello,
If someone could help me with getting a gradient in the background of a button, I'd appreciate it.

I would expect the following code to make the button's background be a gradient from red to white vertically from the top of the button to the bottom.

Qt Code:
  1. QPushButton *b = new QPushButton("Hi", this);
  2.  
  3. QLinearGradient linearGrad(0, 0, 0, b->height());
  4. linearGrad.setColorAt(0, Qt::red);
  5. linearGrad.setColorAt(1, Qt::white);
  6.  
  7. QPalette palette = b->palette();
  8. palette.setBrush(QPalette::Button, QBrush(linearGrad));
  9. b->setPalette(palette);
To copy to clipboard, switch view to plain text mode 

All it does, though, is make the button black. Since it makes the button black, I know that I am successfully changing the palette and reapplying it, but I'm just not changing it in the right way.

Any help would be great.

Thanks,
Derek