当前位置: 首页>>代码示例>>C++>>正文


C++ QColor::dark方法代码示例

本文整理汇总了C++中QColor::dark方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::dark方法的具体用法?C++ QColor::dark怎么用?C++ QColor::dark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QColor的用法示例。


在下文中一共展示了QColor::dark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawArrowNeedle

/*!
  Draw a needle looking like an arrow

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center center of the needle
  \param length Length of the needle
  \param width Width of the needle
  \param direction Current Direction
  \param hasKnob With/Without knob
*/
void QwtDialSimpleNeedle::drawArrowNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, int width,
    double direction, bool hasKnob )
{
    direction *= M_PI / 180.0;

    painter->save();

    if ( width <= 0 )
    {
        width = ( int )qMax( length * 0.06, 9.0 );
        if ( width % 2 == 0 )
            width++;
    }

    const int peak = 3;
    const QPoint p1( center.x() + 1, center.y() + 1 );
    const QPoint p2 = qwtPolar2Pos( p1, length - peak, direction );
    const QPoint p3 = qwtPolar2Pos( p1, length, direction );

    QPolygon pa( 5 );
    pa.setPoint( 0, qwtPolar2Pos( p1, width / 2, direction - M_PI_2 ) );
    pa.setPoint( 1, qwtPolar2Pos( p2, 1, direction - M_PI_2 ) );
    pa.setPoint( 2, p3 );
    pa.setPoint( 3, qwtPolar2Pos( p2, 1, direction + M_PI_2 ) );
    pa.setPoint( 4, qwtPolar2Pos( p1, width / 2, direction + M_PI_2 ) );

    painter->setPen( Qt::NoPen );
    painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) );
    painter->drawPolygon( pa );

    QPolygon shadowPa( 3 );

    const int colorOffset = 10;

    int i;
    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i] );

    const QColor midColor = palette.color( colorGroup, QPalette::Mid );

    painter->setPen( midColor.dark( 100 + colorOffset ) );
    painter->drawPolyline( shadowPa );

    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i + 2] );

    painter->setPen( midColor.dark( 100 - colorOffset ) );
    painter->drawPolyline( shadowPa );

    if ( hasKnob )
    {
        drawKnob( painter, center, qRound( width * 1.3 ),
            palette.brush( colorGroup, QPalette::Base ),
            false );
    }

    painter->restore();
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:72,代码来源:qwt_dial_needle.cpp

示例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;
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:26,代码来源:cockpit_grid.cpp

示例3: 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 );
    }
}
开发者ID:lolsborn,项目名称:RovDash,代码行数:39,代码来源:qwt_dial_needle.cpp

示例4: applyQtColors

static void applyQtColors( KSharedConfigPtr kglobalcfg, QSettings& settings, QPalette& newPal )
{
  QStringList actcg, inactcg, discg;
  /* export kde color settings */
  int i;
  for (i = 0; i < QPalette::NColorRoles; i++)
     actcg   << newPal.color(QPalette::Active,
                (QPalette::ColorRole) i).name();
  for (i = 0; i < QPalette::NColorRoles; i++)
     inactcg << newPal.color(QPalette::Inactive,
                (QPalette::ColorRole) i).name();
  for (i = 0; i < QPalette::NColorRoles; i++)
     discg   << newPal.color(QPalette::Disabled,
                (QPalette::ColorRole) i).name();

  settings.setValue("/qt/Palette/active", actcg);
  settings.setValue("/qt/Palette/inactive", inactcg);
  settings.setValue("/qt/Palette/disabled", discg);

  // export kwin's colors to qtrc for kstyle to use
  KConfigGroup wmCfgGroup(kglobalcfg, "WM");

  // active colors
  QColor clr = newPal.color( QPalette::Active, QPalette::Background );
  clr = wmCfgGroup.readEntry("activeBackground", clr);
  settings.setValue("/qt/KWinPalette/activeBackground", clr.name());
  if (QPixmap::defaultDepth() > 8)
    clr = clr.dark(110);
  clr = wmCfgGroup.readEntry("activeBlend", clr);
  settings.setValue("/qt/KWinPalette/activeBlend", clr.name());
  clr = newPal.color( QPalette::Active, QPalette::HighlightedText );
  clr = wmCfgGroup.readEntry("activeForeground", clr);
  settings.setValue("/qt/KWinPalette/activeForeground", clr.name());
  clr = newPal.color( QPalette::Active,QPalette::Background );
  clr = wmCfgGroup.readEntry("frame", clr);
  settings.setValue("/qt/KWinPalette/frame", clr.name());
  clr = wmCfgGroup.readEntry("activeTitleBtnBg", clr);
  settings.setValue("/qt/KWinPalette/activeTitleBtnBg", clr.name());

  // inactive colors
  clr = newPal.color(QPalette::Inactive, QPalette::Background);
  clr = wmCfgGroup.readEntry("inactiveBackground", clr);
  settings.setValue("/qt/KWinPalette/inactiveBackground", clr.name());
  if (QPixmap::defaultDepth() > 8)
    clr = clr.dark(110);
  clr = wmCfgGroup.readEntry("inactiveBlend", clr);
  settings.setValue("/qt/KWinPalette/inactiveBlend", clr.name());
  clr = newPal.color(QPalette::Inactive, QPalette::Background).dark();
  clr = wmCfgGroup.readEntry("inactiveForeground", clr);
  settings.setValue("/qt/KWinPalette/inactiveForeground", clr.name());
  clr = newPal.color(QPalette::Inactive, QPalette::Background);
  clr = wmCfgGroup.readEntry("inactiveFrame", clr);
  settings.setValue("/qt/KWinPalette/inactiveFrame", clr.name());
  clr = wmCfgGroup.readEntry("inactiveTitleBtnBg", clr);
  settings.setValue("/qt/KWinPalette/inactiveTitleBtnBg", clr.name());

  KConfigGroup kdeCfgGroup(kglobalcfg, "KDE");
  settings.setValue("/qt/KDE/contrast", kdeCfgGroup.readEntry("contrast", 7));
}
开发者ID:KDE,项目名称:kde-workspace,代码行数:59,代码来源:krdb.cpp

示例5: 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;
}
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:10,代码来源:document.cpp

示例6: colorTheme

QPalette CockpitGrid::colorTheme( const QColor &base ) const
{
    QPalette palette;
    palette.setColor( QPalette::Base, base );
    palette.setColor( QPalette::Window, base.dark( 150 ) );
    palette.setColor( QPalette::Mid, base.dark( 110 ) );
    palette.setColor( QPalette::Light, base.light( 170 ) );
    palette.setColor( QPalette::Dark, base.dark( 170 ) );
    palette.setColor( QPalette::Text, base.dark( 200 ).light( 800 ) );
    palette.setColor( QPalette::WindowText, base.dark( 200 ) );

    return palette;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:13,代码来源:cockpit_grid.cpp

示例7: setupPainter

void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const
{
    QColor highlight = qxt_p().palette().color(QPalette::Highlight);
    QLinearGradient gradient(x1, y1, x2, y2);
    gradient.setColorAt(0, highlight.dark(120));
    gradient.setColorAt(1, highlight.light(108));
    painter->setBrush(gradient);

    if (orientation == Qt::Horizontal)
        painter->setPen(QPen(highlight.dark(130), 0));
    else
        painter->setPen(QPen(highlight.dark(150), 0));
}
开发者ID:dshean,项目名称:trunk,代码行数:13,代码来源:qxtspanslider.cpp

示例8: setupPainter

void CSliderMultiPos::setupPainter(QPainter* painter,QPointF point1,QPointF point2,QColor color){

    QLinearGradient gradient(point1,point2);
    gradient.setColorAt(0, color.dark(120));
    gradient.setColorAt(1, color.light(108));
    painter->setBrush(gradient);

    if( this->orientation()==Qt::Horizontal) {
        painter->setPen(QPen(color.dark(130), 0));
    }
    else{
        painter->setPen(QPen(color.dark(150), 0));
    }
}
开发者ID:anjinkristou,项目名称:SliderMutliPos,代码行数:14,代码来源:CSliderMultiPos.cpp

示例9: black

void
TracingItem::setStroke(Chart::Style, QColor color, bool)
{
    const QColor black(Qt::black);
    const QPen outline(black);
    QColor alphaColor(color);
    QColor darkColor;

    darkColor = color.darker(180);
    alphaColor.setAlpha(196);
    QBrush alphaBrush(alphaColor);

    my.pointCurve->setLegendColor(color);

    my.spanSymbol->setWidth(6);
    my.spanSymbol->setBrush(alphaBrush);
    my.spanSymbol->setPen(outline);

    my.dropSymbol->setWidth(1);
    my.dropSymbol->setBrush(Qt::NoBrush);
    my.dropSymbol->setPen(outline);

    my.pointSymbol->setSize(8);
    my.pointSymbol->setColor(color);
    my.pointSymbol->setPen(outline);

    my.selectionSymbol->setSize(8);
    my.selectionSymbol->setColor(color.dark(180));
    my.selectionSymbol->setPen(outline);
}
开发者ID:goodwinos,项目名称:pcp,代码行数:30,代码来源:tracing.cpp

示例10: paintEvent

void KCSelectAllButton::paintEvent(QPaintEvent* event)
{
    // the painter
    QPainter painter(this);
    painter.setClipRect(event->rect());

    // if all cells are selected
    if (m_selection->isAllSelected() &&
            !m_selection->referenceSelectionMode() && m_cellToolIsActive) {
        // selection brush/color
        QColor selectionColor(palette().highlight().color());
        selectionColor.setAlpha(127);
        const QBrush selectionBrush(selectionColor);

        painter.setPen(selectionColor.dark(150));
        painter.setBrush(selectionBrush);
    } else {
        // background brush/color
        const QBrush backgroundBrush(palette().window());
        const QColor backgroundColor(backgroundBrush.color());

        painter.setPen(backgroundColor.dark(150));
        painter.setBrush(backgroundBrush);
    }
    painter.drawRect(rect().adjusted(0, 0, -1, -1));
}
开发者ID:KDE,项目名称:koffice,代码行数:26,代码来源:Headers.cpp

示例11: 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);
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:25,代码来源:spreadsheet.cpp

示例12: paint

void Button::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {

	if (d->buttonFace) {
		painter->setPen(Qt::NoPen);
		painter->setBrush(QColor(0, 0, 0, 64));
		painter->drawRoundRect(rect().translated(2, 2));

		QLinearGradient gradient(rect().topLeft(), rect().bottomRight());
		const QColor col = d->brush.color();
		gradient.setColorAt(0, col);
		gradient.setColorAt(1, col.dark(200));
		painter->setBrush(gradient);
		painter->setPen(QPen(Qt::black, 1));
		painter->drawRoundRect(rect());

		int flags = Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap;
		QFont font;
		font.setPixelSize(7);
		painter->setFont(font);
		painter->setBrush(Qt::black);
		painter->setPen(Qt::black);
		painter->drawText( rect().adjusted( 10, 10, -10, -10 ), flags, d->text);
	} else {
		painter->setPen(Qt::NoPen);
		painter->setBrush(QColor(0, 0, 0, 128));
		painter->drawRoundRect(rect());
	}

}
开发者ID:Balex93,项目名称:telldus,代码行数:29,代码来源:button.cpp

示例13: 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;
}
开发者ID:Zekom,项目名称:kcachegrind,代码行数:35,代码来源:listutils.cpp

示例14: 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);
}
开发者ID:thibautquentinjacob,项目名称:BespinMod,代码行数:8,代码来源:resizecorner.cpp

示例15: resizeEvent

void Plot::resizeEvent(QResizeEvent *event)
{
    d_directPainter->reset();
    QwtPlot::resizeEvent(event);

    const QColor color(46, 74, 95);
    const QRect cr = canvas()->contentsRect();
    QLinearGradient gradient(cr.topLeft(), cr.topRight());
    gradient.setColorAt(0.0, color.light(130));
    gradient.setColorAt(0.2, color.dark(110));
    gradient.setColorAt(0.7, color);
    gradient.setColorAt(1.0, color.dark(150));

    QPalette pal = canvas()->palette();
    pal.setBrush(QPalette::Window, QBrush(gradient));
    canvas()->setPalette(pal);
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:17,代码来源:plot.cpp


注:本文中的QColor::dark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。