本文整理汇总了C++中QColor::light方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::light方法的具体用法?C++ QColor::light怎么用?C++ QColor::light使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::light方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void PluginSlider::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QColor color = themer()->get_color("PluginSlider:value");
QColor background = themer()->get_color("PluginSlider:background");
if (highlight) {
color = color.light(110);
background = background.light(105);
}
// avoid painting at 0, it looks bad...
if (m_xpos <= 1) m_xpos = 2;
painter.setBrush(background);
painter.setPen(themer()->get_color("PluginSlider:text"));
QRectF rect(0.0, 0.0, width() - 0.5, height() - 0.5);
painter.drawRect(rect);
painter.fillRect(1, 1, m_xpos - 2, height() - 2, QBrush(color));
if (m_port->get_hint() == PluginPort::INT_CONTROL) {
painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number((int)m_value));
} else {
painter.drawText(0, 0, width(), height(), Qt::AlignCenter, QString::number(m_value, 'f', 2));
}
}
示例2: colorTheme
QPalette CockpitGrid::colorTheme(const QColor &base) const
{
const QColor background = base.dark(150);
const QColor foreground = base.dark(200);
const QColor mid = base.dark(110);
const QColor dark = base.dark(170);
const QColor light = base.light(170);
const QColor text = foreground.light(800);
QPalette palette;
for ( int i = 0; i < QPalette::NColorGroups; i++ )
{
QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
palette.setColor(cg, QPalette::Base, base);
palette.setColor(cg, QPalette::Window, background);
palette.setColor(cg, QPalette::Mid, mid);
palette.setColor(cg, QPalette::Light, light);
palette.setColor(cg, QPalette::Dark, dark);
palette.setColor(cg, QPalette::Text, text);
palette.setColor(cg, QPalette::WindowText, foreground);
}
return palette;
}
示例3: paint
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
int x = -7;
int y = -7;
int width = 20;
int height = 20;
x = -10;
y = -10;
QColor color;
QColor colorDark;
switch(nodeType)
{
case InterpPoints:
color = QColor(Qt::blue);
colorDark = QColor(Qt::darkBlue);
break;
case PseudoPoints:
color = QColor(Qt::green);
colorDark = QColor(Qt::darkGreen);
break;
case ControlPoints:
x = -7;
y = -7;
width = 15;
height = 15;
color = QColor(Qt::yellow);
colorDark = QColor(Qt::darkYellow);
break;
case CurvePoints:
x = -2;
y = -2;
width = 5;
height = 5;
color = QColor(Qt::red);
colorDark = QColor(Qt::darkRed);
break;
default:
color = QColor(Qt::gray);
colorDark = QColor(Qt::darkGray);
break;
}
QRadialGradient gradient(-3, -3, 10);
if (option->state & QStyle::State_Sunken) {
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, color.light(120));
gradient.setColorAt(0, colorDark.light(120));
} else {
gradient.setColorAt(0, color);
gradient.setColorAt(1, colorDark);
}
painter->setBrush(gradient);
painter->setPen(QPen(Qt::black, 0));
painter->drawEllipse(x, y, width, height);
}
示例4: drawNeedle
/*!
Draw the needle
\param painter Painter
\param length Length of the needle
\param colorGroup Color group, used for painting
*/
void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const
{
if ( d_style == ThinStyle )
{
const double width = qMax( length / 6.0, 3.0 );
const int colorOffset = 10;
const QColor light = palette().color( colorGroup, QPalette::Light );
const QColor dark = palette().color( colorGroup, QPalette::Dark );
qwtDrawShadedPointer( painter,
dark.light( 100 + colorOffset ),
dark.dark( 100 + colorOffset ),
length, width );
painter->rotate( 180.0 );
qwtDrawShadedPointer( painter,
light.light( 100 + colorOffset ),
light.dark( 100 + colorOffset ),
length, width );
const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
drawKnob( painter, width, baseBrush, true );
}
else
{
qwtDrawTriangleNeedle( painter, palette(), colorGroup, length );
}
}
示例5: paintEvent
void KoContextBarButton::paintEvent(QPaintEvent*)
{
QStylePainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QStyleOptionToolButton opt;
initStyleOption(&opt);
const QColor bgColor = palette().color(QPalette::Highlight);
QColor color = bgColor.dark(CONTEXTBAR_BACKGROUND_DARKNESS);
QColor borderColor = bgColor.light(CONTEXTBAR_BORDER_LIGHTNESS);
if (opt.state & QStyle::State_MouseOver && opt.state & QStyle::State_Enabled) {
color = color.light(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
borderColor = borderColor.lighter(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
}
const QRectF rectF = QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5);
QPainterPath path;
path.addRoundRect(rectF, CONTEXTBAR_RADIUS, CONTEXTBAR_RADIUS);
if (m_fadingValue < 255) {
color.setAlpha(m_fadingValue);
}
// Background
painter.fillPath(path, color);
if (opt.state & QStyle::State_Raised && opt.state & QStyle::State_Enabled) {
// Bottom shadow
QLinearGradient gradient(rectF.bottomLeft(), rectF.bottomLeft() - QPoint(0, 5));
gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
gradient.setColorAt(1, Qt::transparent);
painter.fillPath(path, gradient);
// Left shadow
gradient.setFinalStop(rectF.bottomLeft() + QPoint(3, 0));
painter.fillPath(path, gradient);
}
else {
// Top shadow
QLinearGradient gradient(rectF.topLeft(), rectF.topLeft() + QPoint(0, 5));
gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
gradient.setColorAt(1, Qt::transparent);
painter.fillPath(path, gradient);
// Left shadow
gradient.setFinalStop(rectF.topLeft() + QPoint(5, 0));
painter.fillPath(path, gradient);
}
// Border
painter.setPen(QPen(borderColor, 0));
painter.drawPath(path);
// Content
painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
}
示例6: paintEvent
void BBTCOView::paintEvent( QPaintEvent * )
{
QPainter p( this );
QColor col = m_bbTCO->m_useStyleColor
? p.pen().brush().color()
: m_bbTCO->colorObj();
if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
{
col = QColor( 160, 160, 160 );
}
if( isSelected() == true )
{
col = QColor( qMax( col.red() - 128, 0 ),
qMax( col.green() - 128, 0 ), 255 );
}
QLinearGradient lingrad( 0, 0, 0, height() );
lingrad.setColorAt( 0, col.light( 130 ) );
lingrad.setColorAt( 1, col.light( 70 ) );
p.fillRect( rect(), lingrad );
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width()-2;
x += static_cast<int>( t * pixelsPerTact() ) )
{
p.setPen( col.light( 80 ) );
p.drawLine( x, 1, x, 5 );
p.setPen( col.light( 120 ) );
p.drawLine( x, height() - 6, x, height() - 2 );
}
}
p.setPen( col.lighter( 130 ) );
p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 );
p.setPen( col.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );
p.setFont( pointSize<8>( p.font() ) );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
p.setPen( textColor() );
p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
if( m_bbTCO->isMuted() )
{
p.drawPixmap( 3, p.fontMetrics().height() + 1,
embed::getIconPixmap( "muted", 16, 16 ) );
}
}
示例7: updateColor
void SpreadSheet::updateColor(QTableWidgetItem *item)
{
QPixmap pix(16, 16);
QColor col;
if (item)
col = item->backgroundColor();
if (!col.isValid())
col = palette().base().color();
QPainter pt(&pix);
pt.fillRect(0, 0, 16, 16, col);
QColor lighter = col.light();
pt.setPen(lighter);
QPoint lightFrame[] = { QPoint(0, 15), QPoint(0, 0), QPoint(15, 0) };
pt.drawPolyline(lightFrame, 3);
pt.setPen(col.dark());
QPoint darkFrame[] = { QPoint(1, 15), QPoint(15, 15), QPoint(15, 1) };
pt.drawPolyline(darkFrame, 3);
pt.end();
colorAction->setIcon(pix);
}
示例8: textChanged
void NumberedTextView::textChanged( int pos, int removed, int added )
{
Q_UNUSED( pos );
if ( removed == 0 && added == 0 )
return;
QTextBlock block = highlight.block();
QTextBlockFormat fmt = block.blockFormat();
QColor bg = view->palette().base().color();
fmt.setBackground( bg );
highlight.setBlockFormat( fmt );
int lineCount = 1;
for ( QTextBlock block = view->document()->begin();
block.isValid(); block = block.next(), ++lineCount )
{
if ( lineCount == markedLine )
{
fmt = block.blockFormat();
QColor bg = Qt::red;
fmt.setBackground( bg.light(150) );
highlight = QTextCursor( block );
highlight.movePosition( QTextCursor::EndOfBlock, QTextCursor::KeepAnchor );
highlight.setBlockFormat( fmt );
break;
}
}
}
示例9: colorPixmap
QPixmap colorPixmap(int w, int h, QColor c)
{
static QPixmap* pixs[37];
static QColor cols[37];
static bool inited = false;
if (!inited) {
for (int i=0;i<37;i++) pixs[i]=0;
inited = true;
}
int hash = (w+h+c.red()+c.green()+c.blue()) % 37;
if (pixs[hash]) {
if ((pixs[hash]->width() == w) &&
(pixs[hash]->height() == h) &&
(cols[hash] == c))
return *pixs[hash];
delete pixs[hash];
}
QPixmap* pix = new QPixmap(w, h);
pix->fill(c);
QPainter p(pix);
p.setPen(c.light());
p.drawLine(0, 0, w-1, 0);
p.drawLine(0, 0, 0, h-1);
p.setPen(c.dark());
p.drawLine(w-1, 0, w-1, h-1);
p.drawLine(0, h-1, w-1, h-1);
pixs[hash] = pix;
cols[hash] = c;
return *pix;
}
示例10: paintEvent
void Snake::paintEvent(QPaintEvent *event)
{//Paint the screen
QPainter painter(this);
QRect rect = QRect(10,10,600,600);
painter.fillRect(rect,Qt::white);
//painter.setRenderHint(QPainter::Antialiasing);
for(int i = header_Index;i != tail_Index;i=(i+1)%Max)//Draw the snake
{
int sx=SnakeBody[i][0]*step+10;
int sy=SnakeBody[i][1]*step+10;
QBrush brush;QPen pen;
QColor color =Qt::green;
painter.setBrush(color);
painter.drawRect(sx,sy,step,step);
pen.setColor(color.light(200));
pen.setWidth(1);
painter.setPen(pen);
painter.drawLine(sx,sy,sx,sy+step);
painter.drawLine(sx,sy+step,sx+step,sy+step);
painter.drawLine(sx,sy,sx+step,sy);
painter.drawLine(sx+step,sy,sx+step,sy+step);
}
painter.setPen(Qt::NoPen);
painter.setBrush(getColor());
if(timer->isActive())//Draw food
painter.drawRect(eat_X*step+10,eat_Y*step+10,step,step);
}
示例11: palette
void
ResizeCorner::setColor(const QColor &c)
{
QColor bgc = (c.value() > 100) ? c.dark(130) : c.light(120);
QPalette pal = palette();
pal.setColor(backgroundRole(), bgc);
setPalette(pal);
}
示例12: setColor
void KNoteTip::setColor(const QColor &fg, const QColor &bg)
{
QPalette newpalette = palette();
newpalette.setColor(QColorGroup::Background, bg);
newpalette.setColor(QColorGroup::Foreground, fg);
newpalette.setColor(QColorGroup::Base, bg); // text background
newpalette.setColor(QColorGroup::Text, fg); // text color
newpalette.setColor(QColorGroup::Button, bg);
// the shadow
newpalette.setColor(QColorGroup::Midlight, bg.light(110));
newpalette.setColor(QColorGroup::Shadow, bg.dark(116));
newpalette.setColor(QColorGroup::Light, bg.light(180));
newpalette.setColor(QColorGroup::Dark, bg.dark(108));
setPalette(newpalette);
// set the text color
mPreview->setColor(fg);
}
示例13: gradient
static QGradient gradient(const QColor &color, const QRect &rect)
{
QColor c = color;
c.setAlpha(160);
QLinearGradient result(rect.topLeft(), rect.bottomRight());
result.setColorAt(0, c.dark(150));
result.setColorAt(0.5, c.light(200));
result.setColorAt(1, c.dark(150));
return result;
}
示例14: setColor
void LineChart::setColor(const QColor &symbolColor)
{
setRenderHint(QwtPlotCurve::RenderAntialiased);
QColor color = symbolColor;
QPen pen = QPen(color);
pen.setWidthF(PEN_WIDTH);
setPen(pen);
setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
symbolColor.light(150), symbolColor, QSize(8, 8)));
}
示例15: paint
void QGILineBinder::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if( ! this->isValid() ) return;// schedule our own destruction here.
QVariant var;
static const double Pi = 3.14159265358979323846264338327950288419717;
static double TwoPi = 2.0 * Pi;
var = this->property("width");
qreal lineWidth = (var.isValid() ? var.toDouble() : 2.0);
var = this->property("color");
QColor lineColor = (var.isValid() ? var.value<QColor>() : Qt::black);
var = this->property("style");
int lineStyle = (var.isValid() ? var.toInt() : Qt::SolidLine);
if( Qt::NoPen == lineStyle ) lineStyle = Qt::SolidLine;
Qt::PenCapStyle capS(Qt::RoundCap);
Qt::PenJoinStyle joinS(Qt::RoundJoin);
// Draw the line itself
QLineF line(impl->pts.first, impl->pts.second);
var = this->property("alpha");
if( var.isValid() ) lineColor.setAlpha( var.toInt() );
painter->save();
painter->setPen(QPen(lineColor, lineWidth, Qt::PenStyle(lineStyle), capS, joinS));
painter->drawLine(line);
painter->restore();
if( this->property("drawArrows").toInt() )
{
var = this->property("arrowSize");
qreal arrowSize = var.isValid() ? var.toDouble() : Impl::defaultArrowSize;
// Draw the arrows if there's enough room
double angle = std::acos(line.dx() / line.length());
if (line.dy() >= 0)
{
angle = TwoPi - angle;
}
QPointF sourceArrowP1 = impl->pts.first + QPointF(std::sin(angle + Pi / 3) * arrowSize,
std::cos(angle + Pi / 3) * arrowSize);
QPointF sourceArrowP2 = impl->pts.first + QPointF(std::sin(angle + Pi - Pi / 3) * arrowSize,
std::cos(angle + Pi - Pi / 3) * arrowSize);
QPointF destArrowP1 = impl->pts.second + QPointF(std::sin(angle - Pi / 3) * arrowSize,
std::cos(angle - Pi / 3) * arrowSize);
QPointF destArrowP2 = impl->pts.second + QPointF(std::sin(angle - Pi + Pi / 3) * arrowSize,
std::cos(angle - Pi + Pi / 3) * arrowSize);
painter->setPen(QPen(lineColor, 2, Qt::SolidLine, capS, joinS ));
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2, Qt::WindingFill);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2, Qt::WindingFill);
}
if( this->isSelected() )
{ // doesn't seem to do what i want?
painter->setPen( QPen(lineColor.light(), 1, Qt::DotLine, capS, joinS));
painter->drawLine( line );
}
}