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
//make color
//check conversion
testColor = testColor.toHsl();
testColor = testColor.fromHsl(120,50,50,255);
qDebug() << testColor.isValid();
qDebug() << testColor.spec();
//set lable colors
ui->label_1->setText("hi");
//palette->setColor(QPalette::WindowText, Qt::blue); <- works
palette
->setColor
(QPalette::WindowText, testColor
); <
- see no color, shows up black
ui->label_1->setPalette(*palette);
//make color
QColor testColor;
//check conversion
testColor = testColor.toHsl();
testColor = testColor.fromHsl(120,50,50,255);
qDebug() << testColor.isValid();
qDebug() << testColor.spec();
//set lable colors
ui->label_1->setText("hi");
QPalette *palette = new QPalette;
//palette->setColor(QPalette::WindowText, Qt::blue); <- works
palette->setColor(QPalette::WindowText, testColor); <- see no color, shows up black
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
QVector<QColor> colorvec;
colorvec.resize(particlemass_len);
for (int i=0;i<particlemass_len;i++)
{
int hue = i * 359/particlemass_len;
int saturation = 80;
int lightness = 50;
int alpha = 255;
colorvec
[i
] = QColor::fromHsl(hue,saturation,lightness,alpha
);
}
QVector<QColor> colorvec;
colorvec.resize(particlemass_len);
for (int i=0;i<particlemass_len;i++)
{
int hue = i * 359/particlemass_len;
int saturation = 80;
int lightness = 50;
int alpha = 255;
colorvec[i] = QColor::fromHsl(hue,saturation,lightness,alpha);
}
To copy to clipboard, switch view to plain text mode
Bookmarks