I tied convert this stylesheet to painter, but I'm failed.

stylesheet
Qt Code:
  1. "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);"
To copy to clipboard, switch view to plain text mode 

painter
Qt Code:
  1. QLinearGradient linearGrad(0, 0, 0, 1);
  2. linearGrad.setColorAt(0, QColor("#e7effd"));
  3. linearGrad.setColorAt(1, QColor("#cbdaf1"));
  4.  
  5. painter->fillRect(option.rect, QBrush(linearGrad));
To copy to clipboard, switch view to plain text mode 

What is wrong ?