Hi guys,

i'm trying to make a color map for plotting and want to use hsl colors. was trying to figure out how to properly use it but been stuck on it for a while now

Qt Code:
  1. //make color
  2. QColor testColor;
  3.  
  4. //check conversion
  5. testColor = testColor.toHsl();
  6. testColor = testColor.fromHsl(120,50,50,255);
  7.  
  8. qDebug() << testColor.isValid();
  9. qDebug() << testColor.spec();
  10.  
  11. //set lable colors
  12. ui->label_1->setText("hi");
  13. QPalette *palette = new QPalette;
  14. //palette->setColor(QPalette::WindowText, Qt::blue); <- works
  15. palette->setColor(QPalette::WindowText, testColor); <- see no color, shows up black
  16. ui->label_1->setPalette(*palette);
To copy to clipboard, switch view to plain text mode 

i made a quick gui with a lable which i want to apply the hsl color to. but it seems to be not working. am i making a basic syntax/logic mistake here? the output from the debug statments is:

true
4 //= HSL

thx for the help!


PS: this is what i actually want to achieve. A list of colors to save in a vector and use it for different data types
Qt Code:
  1. QVector<QColor> colorvec;
  2. colorvec.resize(particlemass_len);
  3.  
  4. for (int i=0;i<particlemass_len;i++)
  5. {
  6. int hue = i * 359/particlemass_len;
  7. int saturation = 80;
  8. int lightness = 50;
  9. int alpha = 255;
  10. colorvec[i] = QColor::fromHsl(hue,saturation,lightness,alpha);
  11. }
To copy to clipboard, switch view to plain text mode