Hello all,

I try to make a classic color scale using two colors; the aim is to enter the color start and the color end and the QLinearGradient will calculate all colours for me ; So I can get it using QImage::colorTable();

I didn't succeed so I send you a piece of my code:
Qt Code:
  1. QColor start = Qt::red;
  2. QColor stop = Qt::green;
  3.  
  4.  
  5. QLinearGradient linearGrad(QPointF(100,100), QPointF(200, 200));
  6. linearGrad.setColorAt(0, start);
  7. linearGrad.setColorAt(1, stop);
  8.  
  9. // create image and fill it with gradient
  10. QImage image(100, 100, QImage::Format_ARGB32);
  11. QPainter painter(&image);
  12. painter.fillRect(image.rect(),linearGrad);
  13.  
  14. // get all colors from the table
  15. QVector<QRgb> tmpColorVec = image.colorTable();
  16. qDebug(QString::number(tmpColorVec.count()).toAscii());
  17.  
  18. for (int i = 0 ; i < tmpColorVec.count(); ++i)
  19. {
  20. QRgb color = tmpColorVec.at(i);
  21. qDebug("R = " + QString::number(qRed(color)).toAscii() +
  22. " G = " + QString::number(qGreen(color)).toAscii() +
  23. " B = " + QString::number(qBlue(color)).toAscii());
  24. }
To copy to clipboard, switch view to plain text mode 

Questions : What I do wrong?
What should I do?

Thanks to all

David