本文整理汇总了C++中QColor::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::value方法的具体用法?C++ QColor::value怎么用?C++ QColor::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: summarize
QString Zones::summarize(int rnum, QVector<double> &time_in_zone) const
{
assert(rnum < ranges.size());
ZoneRange *range = ranges[rnum];
assert(time_in_zone.size() == range->zones.size());
QString summary;
if(range->cp > 0){
summary += "<table align=\"center\" width=\"70%\" border=\"0\">";
summary += "<tr><td align=\"center\">";
summary += tr("Critical Power: %1").arg(range->cp);
summary += "</td></tr></table>";
}
summary += "<table align=\"center\" width=\"70%\" ";
summary += "border=\"0\">";
summary += "<tr>";
summary += "<td align=\"center\">Zone</td>";
summary += "<td align=\"center\">Description</td>";
summary += "<td align=\"center\">Low</td>";
summary += "<td align=\"center\">High</td>";
summary += "<td align=\"center\">Time</td>";
summary += "</tr>";
QColor color = QApplication::palette().alternateBase().color();
color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value());
for (int zone = 0; zone < time_in_zone.size(); ++zone) {
if (time_in_zone[zone] > 0.0) {
QString name, desc;
int lo, hi;
zoneInfo(rnum, zone, name, desc, lo, hi);
if (zone % 2 == 0)
summary += "<tr bgcolor='" + color.name() + "'>";
else
summary += "<tr>";
summary += QString("<td align=\"center\">%1</td>").arg(name);
summary += QString("<td align=\"center\">%1</td>").arg(desc);
summary += QString("<td align=\"center\">%1</td>").arg(lo);
if (hi == INT_MAX)
summary += "<td align=\"center\">MAX</td>";
else
summary += QString("<td align=\"center\">%1</td>").arg(hi);
summary += QString("<td align=\"center\">%1</td>")
.arg(time_to_string((unsigned) round(time_in_zone[zone])));
summary += "</tr>";
}
}
summary += "</table>";
return summary;
}
示例2: QLabel
ColorLabel::ColorLabel(QWidget *parent, const QColor &c, int id, const QString &text)
: QLabel(parent)
, m_id(id)
{
setText(text);
QPalette palette;
palette.setColor(backgroundRole(), c);
palette.setColor(QPalette::WindowText, !c.value());
setPalette(palette);
setAutoFillBackground(true);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setFrameShape(StyledPanel);
setFrameShadow(Sunken);
setLineWidth(2);
}
示例3: frameColor
QColor TimelineColorScheme::frameColor(bool present, bool active) const
{
QColor color = Qt::transparent;
if (present && !active) {
color = m_d->baseColor;
} else if (present && active) {
QColor bgColor = qApp->palette().color(QPalette::Base);
int darkenCoeff = bgColor.value() > 128 ? 130 : 80;
color = m_d->baseColor.darker(darkenCoeff);
} else if (!present && active) {
QColor bgColor = qApp->palette().color(QPalette::Base);
return blendColors(m_d->baseColor, bgColor, 0.2);
}
return color;
}
示例4: getSample
QPixmap BrushStyle::getSample(qreal scale, qreal alpha, bool selected, const QColor &color, bool emptyBackground)
{
QPixmap backgroundPixmap( (selected) ? BRUSH_SAMPLE_SELECTED_BG : BRUSH_SAMPLE_BACKGROUND);
if (emptyBackground)
backgroundPixmap.fill(Qt::transparent);
// Scale the sample
QSizeF pointSize(BRUSH_SAMPLE_SIDE, BRUSH_SAMPLE_SIDE);
if (scale != 1.0)
{
pointSize.setWidth(pointSize.width() * scale);
pointSize.setHeight(pointSize.height() * scale);
}
// Apply color and alpha
QColor alphaColor(Qt::black);
if (color.isValid())
alphaColor = color;
if (alpha != 1.0)
alphaColor.setAlphaF(alpha);
// Draw sample in the middle of background
QPainter painter(&backgroundPixmap);
painter.setRenderHint(QPainter::Antialiasing);
QRectF pointRect(QPointF(0, 0), pointSize);
pointRect.moveTo(backgroundPixmap.width() / 2 - pointSize.width() / 2, backgroundPixmap.height() / 2 - pointSize.height() / 2);
if (color.isValid() && color.value() > 210 && color.saturation() < 50)
painter.setPen("#d0d0d0");
else
painter.setPen(Qt::NoPen);
painter.setBrush(alphaColor);
painter.drawEllipse(pointRect);
painter.end();
return backgroundPixmap;
}
示例5: addCustomStylesheet
void EmbeddedWebView::addCustomStylesheet(const QString &css)
{
m_customCss = css;
QWebSettings *s = settings();
QString bgName, fgName;
QColor bg = palette().color(QPalette::Active, QPalette::Base),
fg = palette().color(QPalette::Active, QPalette::Text);
switch (m_colorScheme) {
case ColorScheme::BlackOnWhite:
bgName = QStringLiteral("white !important");
fgName = QStringLiteral("black !important");
break;
case ColorScheme::AdjustedSystem:
{
// This is HTML, and the authors of that markup are free to specify only the background colors, or only the foreground colors.
// No matter what we pass from outside, there will always be some color which will result in unreadable text, and we can do
// nothing except adding !important everywhere to fix this.
// This code attempts to create a color which will try to produce exactly ugly results for both dark-on-bright and
// bright-on-dark segments of text. However, it's pure alchemy and only a limited heuristics. If you do not like this, please
// submit patches (or talk to the HTML producers, hehehe).
const int v = bg.value();
if (v < 96 && fg.value() > 128 + v/2) {
int h,s,vv,a;
fg.getHsv(&h, &s, &vv, &a) ;
fg.setHsv(h, s, 128+v/2, a);
}
bgName = bg.name();
fgName = fg.name();
break;
}
case ColorScheme::System:
bgName = bg.name();
fgName = fg.name();
break;
}
const QString urlPrefix(QStringLiteral("data:text/css;charset=utf-8;base64,"));
const QString myColors(QStringLiteral("body { background-color: %1; color: %2; }\n").arg(bgName, fgName));
s->setUserStyleSheetUrl(QString::fromUtf8(urlPrefix.toUtf8() + (myColors + m_customCss).toUtf8().toBase64()));
}
示例6: setColor
void KTColorPalette::setColor(const QBrush& brush)
{
QColor color = brush.color();
if(color.isValid())
{
if(m_type == Gradient)
{
m_gradientManager->setCurrentColor(color);
}
if(m_displayValueColor && m_outlineAndFillColors && m_colorPicker && m_nameColor && m_luminancePicker)
{
m_colorPicker->setCol(color.hue(), color.saturation ());
if(m_type == Solid)
{
m_outlineAndFillColors->setCurrentColor(color);
}
m_nameColor->setText(color.name ());
m_luminancePicker->setCol(color.hue(), color.saturation(), color.value());
m_containerPalette->setColor( brush );
m_displayValueColor->setColor(color);
}
}
else if(brush.gradient())
{
QGradient gradient(*brush.gradient());
changeBrushType(tr("Gradient"));
m_containerPalette->setColor(gradient);
m_outlineAndFillColors->setCurrentColor(gradient);
if( sender () != m_gradientManager )
{
m_gradientManager->setGradient(gradient);
}
}
emit brushChanged( m_outlineAndFillColors->foreground(),m_outlineAndFillColors->background() );
}
示例7: changeColor
void ColorWheel::changeColor(const QColor &color)
{
if (color == m_currentColor)
{
return;
}
if (color.hue() != m_currentColor.hue())
{
hueChanged(color.hue());
}
if (color.saturation() != m_currentColor.saturation() ||
color.value() != m_currentColor.value() )
{
svChanged(color);
}
//emit colorChanged(color);
update();
}
示例8: getHighlighted
/**
* \return Highlighted color for the given color.
*/
RColor RColor::getHighlighted(const RColor& color, const QColor& bgColor, int minDist) {
if (!color.isValid()) {
return Qt::gray;
}
RColor ret = color;
int vColor = color.value();
int vBgColor = bgColor.value();
// 0 vColor vBgColor 255
// |--------^----------------------------^------------------|
// |<--d1-->|<------------d2------------>|<-------d3------->|
int d1 = qMin(vColor, vBgColor);
//int d2 = qAbs(vColor - vBgColor);
int d3 = 255 - qMax(vColor, vBgColor);
// d3 is big enough: set value to max (highlight):
if (d3>=minDist) {
ret.setHsv(color.hue(), color.saturation(), 255);
}
// d1 is big enough: set value to half (lowlight):
else if (d1>=minDist) {
ret.setHsv(color.hue(), color.saturation(), qMin(vColor, vBgColor)/2);
}
// black on white:
else if (vColor<32 && vBgColor>224) {
ret.setHsv(color.hue(), color.saturation(), 160);
}
// d2 is the only significant distance, set value to medium:
else if (vColor<vBgColor) {
ret.setHsv(color.hue(), color.saturation(), qMin(vColor+minDist, 255));
}
else {
ret.setHsv(color.hue(), color.saturation(), qMax(vColor-minDist, 0));
}
return ret;
}
示例9: paintEvent
void ColorButton::paintEvent(QPaintEvent *event)
{
QToolButton::paintEvent(event);
if (!isEnabled())
return;
QColor color = properColor(m_colorString);
QPainter p(this);
QRect r(0, 0, width() - 2, height() - 2);
p.drawTiledPixmap(r.adjusted(1, 1, -1, -1), tilePixMap(9));
if (isEnabled())
p.setBrush(color);
else
p.setBrush(Qt::transparent);
if (color.value() > 80)
p.setPen(QColor(0x444444));
else
p.setPen(QColor(0x9e9e9e));
p.drawRect(r.translated(1, 1));
if (m_showArrow) {
p.setRenderHint(QPainter::Antialiasing, true);
QVector<QPointF> points;
if (isChecked()) {
points.append(QPointF(2, 3));
points.append(QPointF(8, 3));
points.append(QPointF(5, 9));
} else {
points.append(QPointF(8, 6));
points.append(QPointF(2, 9));
points.append(QPointF(2, 3));
}
p.translate(0.5, 0.5);
p.setBrush(QColor(0xaaaaaa));
p.setPen(QColor(0x444444));
p.drawPolygon(points);
}
}
示例10: mousePressEvent
void ColorWheel::mousePressEvent(QMouseEvent *event)
{
QPoint lastPos = event->pos();
if (mSquareRect.contains(lastPos))
{
mIsInWheel = false;
mIsInSquare = true;
QColor color = pickColor(lastPos);
saturationChanged(color.saturation());
valueChanged(color.value());
}
else if (mWheelRect.contains(lastPos))
{
mIsInWheel = true;
mIsInSquare = false;
QColor color = pickColor(lastPos);
hueChanged(color.hue());
}
}
示例11: setColor
void ColorWheel::setColor(const QColor &color)
{
if (color == m_currentColor)
{
return;
}
if (color.hue() != m_currentColor.hue())
{
hueChanged(color.hue());
}
if (color.saturation() != m_currentColor.saturation() ||
color.value() != m_currentColor.value() )
{
svChanged(color);
}
update();
emit colorSelected(color);
}
示例12: createColor
Transformation Transformation::createColor(QString color) {
Transformation t;
if (color.toLower() != "random") {
QColor c(color);
QColor hsv = c.toHsv();
t.deltaH = hsv.hue();
t.scaleAlpha = hsv.alpha()/255.0;
t.scaleS = hsv.saturation()/255.0;
t.scaleV = hsv.value()/255.0;
t.absoluteColor = true;
} else {
t.deltaH = 1000;
t.absoluteColor = true;
}
//Debug(QString("Abs Color: %1, %2, %3, %4").arg(t.deltaH).arg(t.scaleS).arg(t.scaleV).arg(t.scaleAlpha));
return t;
}
示例13: getColor
void RecSkinColorPalette::getColor(const QColor &averageColor)
{
isDrawEllipse = true;
emit sigMousePressRGB(averageColor.rgb());
hsvValue = averageColor.value();
int width = 359;
int height = 255;
QImage temp(QSize(width, height), QImage::Format_ARGB32);
for(int w = 0; w < width; ++w)
{
for(int h = 0; h < height; ++h)
{
QRgb rgb = QColor::fromHsv(w,h,hsvValue,255).rgb();
QRgb r = qRgba(qRed(rgb), qGreen(rgb), qBlue(rgb), 255);
temp.setPixel(w, h, r);
}
}
drawImage = temp;
QImage tempImage = drawImage.scaled(this->width(),this->height());
bool isTrue = false;
for(int i = 0; i < tempImage.width(); ++i)
{
for(int j = 0; j < tempImage.height(); ++j)
{
if(QColor::fromRgb(tempImage.pixel(i,j)) == averageColor)
{
mousePoint.setX(i);
mousePoint.setY(j);
isTrue = true;
break;
}
}
if(isTrue)
break;
}
update();
}
示例14: setColor
void ColorWheel::setColor(QColor color)
{
// this is a UI updating function, never emit any signals
// and don't call any functions that will emit signals
color = color.toHsv();
if (color == mCurrentColor)
{
return;
}
if (color.hue() == -1) // grayscale color, keep the current hue
{
color.setHsv(mCurrentColor.hue(), color.saturation(), color.value(), color.alpha());
}
mCurrentColor = color;
drawSquareImage(color.hue());
update();
}
示例15: updateChart
//----------------------------------------------------------------------------
// Update Chart
//----------------------------------------------------------------------------
void ReportPieChart::updateChart()
{
mModel->setRowCount( mDataList.size() );
if( mDataList.size() > 0 )
{
// Sort data items
switch( mSortType )
{
case SORT_BY_BALANCE_DESCENDING:
qSort( mDataList.begin(), mDataList.end(), pieDataSortByBalanceDescending );
break;
case SORT_BY_NAME_ASCENDING:
qSort( mDataList.begin(), mDataList.end(), pieDataSortByNameAscending );
break;
}
const int colorRange = COLOR_RANGE;
int step = qMin( MAX_COLOR_STEP, (colorRange / mDataList.size()) );
QColor baseColor = BASE_COLOR.toHsv();
int h = baseColor.hue();
int s = baseColor.saturation();
int v = baseColor.value();
for (int i = 0; i < mDataList.size(); ++i)
{
QColor secondaryLabelColor = ( mDataList[i].mValue > 0 ) ? QColor(Qt::darkGreen) : QColor(Qt::red);
QColor nextColor;
int newH = (h + step*i)%colorRange;
nextColor.setHsv( newH, s, v );
QString valueStr = Transaction::getAmountText( mDataList[i].mValue );
mModel->setData( mModel->index(i,(int)PieView::COLUMN_LABEL), mDataList[i].mName );
mModel->setData( mModel->index(i,(int)PieView::COLUMN_LABEL), nextColor, Qt::DecorationRole );
mModel->setData( mModel->index(i,(int)PieView::COLUMN_VALUE), qAbs(mDataList[i].mValue) );
mModel->setData( mModel->index(i,(int)PieView::COLUMN_SEC_LABEL), valueStr );
mModel->setData( mModel->index(i,(int)PieView::COLUMN_SEC_LABEL), secondaryLabelColor, Qt::DecorationRole );
}
}
updateViewport();
} // ReportPieChart::updateChart