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


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

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


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

示例1: QColor

void OCView_MainWin::showT2(void)
{
  QPalette palette = lblTemp2->palette();;
  QColor colorTxt;//(0,0,0,0);
  QColor colorBack;//(255,255,255,0);

  if (m_data->vehicule.engine.temperature[1].value()>=100) {
    //colorTxt = Qt::black;
    colorBack = Qt::red;
    colorBack = colorBack.darker(120);
  } else {
    //colorTxt = Qt::black;
    colorBack = this->palette().color(QPalette::Window);
  }

  colorTxt = QColor(255-colorBack.red(),255-colorBack.green(),255-colorBack.blue());

  palette.setColor(QPalette::WindowText, colorTxt); // text (setBrush or setColor)
  palette.setColor(lblTemp1->backgroundRole(), colorBack); // background
  lblTemp2->setAutoFillBackground( true );
  lblTemp2->setPalette(palette); // apply the palette to the label

  //lblTemp2->setText(m_data->vehicule.engine.temperature_2.getStr());
  lblTemp2->setText(m_data->vehicule.engine.temperature[1].getStr());
}
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:25,代码来源:ocview_mainwin.cpp

示例2: paintEvent

void DiffSplitterHandle::paintEvent(QPaintEvent *event)
{
	QPainter painter(this);
	int lineHeight = renderer()->lineHeight();
	/*QBrush brush = QBrush(QColor(0, 0, 0), Qt::BrushStyle::SolidPattern);*/
	painter.fillRect(event->rect(), QBrush());
	const QSize& size = this->size();
	QRect paintRect = event->rect();
	//    QRect translatedRect( clipRect.x()+offsetX, clipRect.y()+offsetY, clipRect.width(), clipRect.height() );
	//paintRect.adjust(0, top_, 0, top_);
	renderer()->renderBegin(paintRect);
	int startLine = renderer()->startLine();
	int endLine = renderer()->endLine();
	QColor baseColor = renderer()->theme()->backgroundColor();

	QColor changedColor = baseColor.darker(120);

	for (int line = startLine; line <= endLine; ++line) {

		int changeType = getLineStatus(line);

		if (changeType > 0) {
			painter.fillRect(0, line*lineHeight, size.width(), lineHeight, changedColor);
		}
	}
	renderer()->renderEnd(paintRect);


}
开发者ID:tomv564,项目名称:qt-diff,代码行数:29,代码来源:example2.cpp

示例3: QScrollArea

PanelsWidget::PanelsWidget(QWidget *parent) :
    QScrollArea(parent),
    m_root(new RootWidget(this))
{
    // We want a 900px wide widget with and the scrollbar at the
    // side of the screen.
    m_root->setFixedWidth(900);
    m_root->setContentsMargins(0, 0, 40, 0);
    
    QPalette pal = m_root->palette();
    QColor background = Utils::StyleHelper::mergedColors(
            palette().window().color(), Qt::white, 85);
    pal.setColor(QPalette::All, QPalette::Window, background.darker(102));
    setPalette(pal);
    pal.setColor(QPalette::All, QPalette::Window, background);
    m_root->setPalette(pal);
    // The layout holding the individual panels:
    m_layout = new QGridLayout(m_root);
    m_layout->setColumnMinimumWidth(0, ICON_SIZE + 4);
    m_layout->setSpacing(0);

    setWidget(m_root);
    setFrameStyle(QFrame::NoFrame);
    setWidgetResizable(true);
}
开发者ID:renatofilho,项目名称:QtCreator,代码行数:25,代码来源:projectwindow.cpp

示例4: QScrollArea

PanelsWidget::PanelsWidget( QWidget * parent ) : QScrollArea( parent )
                                               , root_( new RootWidget( this ) )
{
    // We want a 900px wide widget with and the scrollbar at the
    // side of the screen.
    //root_->setMaximumWidth( 900 );
    root_->setContentsMargins( 0, 0, 40, 0 );

    QPalette pal;
    QColor background = Utils::StyleHelper::mergedColors( palette().window().color(), Qt::white, 85);
    pal.setColor(QPalette::All, QPalette::Window, background.darker(102));
    setPalette(pal);
    pal.setColor(QPalette::All, QPalette::Window, background);
    root_->setPalette(pal);

    // The layout holding the individual panels:
    QVBoxLayout *topLayout = new QVBoxLayout(root_);
    topLayout->setMargin(0);
    topLayout->setSpacing(0);

    layout_ = new QGridLayout;
    layout_->setColumnMinimumWidth( 0, Constants::ICON_SIZE + 4 );
    layout_->setSpacing( 0 );
    topLayout->addLayout( layout_ );
    //topLayout->addStretch( 1 );
    setWidget(root_);
    setFrameStyle(QFrame::NoFrame);
    setWidgetResizable(true);
    setFocusPolicy(Qt::NoFocus);
}
开发者ID:hermixy,项目名称:qtplatz,代码行数:30,代码来源:panelswidget.cpp

示例5: paintEvent

void TvolumeView::paintEvent(QPaintEvent* ) {
  QPainter painter(this);
  painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
  painter.setPen(Qt::NoPen);
  QColor noteColor = qApp->palette().text().color();
  if (m_alpha) { // Background if note is detected
      m_pitchColor.setAlpha(m_alpha);
      painter.setBrush(QBrush(m_pitchColor));
      noteColor = qApp->palette().highlightedText().color();
			painter.drawRoundedRect(painter.viewport(), 4, 4);
  }
  painter.setFont(nootFont);
  QString nSymbol = (m_activePause && m_paused) ? "o" : "n";
	QRect nRect = painter.fontMetrics().boundingRect(nSymbol);
	if (m_drawPaused) { // Stop/start highlight
		painter.setBrush(m_overNote ? qApp->palette().highlightedText().color().darker(95) : qApp->palette().highlight().color());
		painter.drawRoundedRect(width() - nRect.width() * 1.8, 0, nRect.width() * 1.8, height(), 50, 50, Qt::RelativeSize);
  }
	if (m_drawPaused) // and note symbol
		painter.setPen(m_overNote ? qApp->palette().highlight().color() : qApp->palette().highlightedText().color());
  else if (m_alpha)
		painter.setPen(noteColor);
  else
		painter.setPen(tc);
	painter.drawText(0, 0, width() - nRect.width() * 0.3, height(), Qt::AlignRight, nSymbol);

  qreal tickWidth = TICK_WIDTH - 1.0;
  for (int i = 1; i < m_ticksCount - 2; i++) { // volume ticks
    if (i >= m_ticksCount * m_minVolume)
      tickWidth = TICK_WIDTH;
		if (m_activePause && m_paused)
			painter.setPen(QPen(disabledColor, tickWidth, Qt::SolidLine, Qt::RoundCap));
    else if (m_volume * m_ticksCount >= i)
      painter.setPen(QPen(m_tickColors[i], tickWidth, Qt::SolidLine, Qt::RoundCap));
    else 
      painter.setPen(QPen(tc, tickWidth, Qt::SolidLine, Qt::RoundCap));
		float ticH = (((float)i * m_hiTickStep + 1.0));
    painter.drawLine(QLineF((i + 1) * (TICK_GAP + TICK_WIDTH) - TICK_WIDTH, (height() - ticH) / 2,
                            (i + 1) * (TICK_GAP + TICK_WIDTH) - TICK_WIDTH, height() - (height() - ticH) / 2));
  }
  if (m_drawKnob) { // volume knob
		painter.setPen(Qt::NoPen);
		QColor knobBrush = qApp->palette().highlight().color(), shade = qApp->palette().text().color();
		if (m_leftButton)
			knobBrush = knobBrush.lighter();
		shade.setAlpha(150);
		painter.setBrush(shade);
		float xPos = (float)(width() - m_noteWidth) * m_minVolume; 
		painter.drawEllipse(QRectF(xPos - height() * 0.5, height() * 0.1, height() * 0.9, height() * 0.9)); // shade
		QLinearGradient lg(xPos, 0, xPos, height());
		lg.setColorAt(0, knobBrush);
		lg.setColorAt(0.3, knobBrush);
		lg.setColorAt(0.8, knobBrush.darker());
		painter.setBrush(QBrush(lg));
		painter.drawEllipse(QRectF(xPos - height() * 0.5, height() * 0.05, height() * 0.9, height() * 0.9));
		painter.setBrush(qApp->palette().highlightedText());
		painter.setPen(QPen(shade, 0.7));
		painter.drawEllipse(QRectF(xPos - height() * 0.27, height() * 0.27, height() * 0.45, height() * 0.45));
  }
}
开发者ID:SeeLook,项目名称:nootka,代码行数:60,代码来源:tvolumeview.cpp

示例6: initWarning

void CaptureDialog::initWarning(RDLabel *warning)
{
  if(!warning)
    return;

  if(warning->devicePixelRatio() >= 2)
    warning->setText(warning->text().replace(lit(".png"), lit("@2x.png")));

  auto calcPaletteFromStyle = [warning](QEvent *) {
    QPalette pal = warning->palette();

    QColor base = pal.color(QPalette::ToolTipBase);

    pal.setColor(QPalette::Foreground, pal.color(QPalette::ToolTipText));
    pal.setColor(QPalette::Window, base);
    pal.setColor(QPalette::Base, base.darker(120));

    warning->setPalette(pal);
  };

  calcPaletteFromStyle(NULL);

  warning->setBackgroundRole(QPalette::Window);
  warning->setForegroundRole(QPalette::Foreground);

  QObject::connect(warning, &RDLabel::mouseMoved,
                   [warning](QMouseEvent *) { warning->setBackgroundRole(QPalette::Base); });
  QObject::connect(warning, &RDLabel::leave,
                   [warning]() { warning->setBackgroundRole(QPalette::Window); });
  QObject::connect(warning, &RDLabel::styleChanged, calcPaletteFromStyle);

  warning->setAutoFillBackground(true);
  warning->setMouseTracking(true);
  warning->setVisible(false);
}
开发者ID:etnlGD,项目名称:renderdoc,代码行数:35,代码来源:CaptureDialog.cpp

示例7: setActiveAppearance

void OverlayAnimator::setActiveAppearance( bool active )
{
    QColor color = mEditor->palette().color(QPalette::Base);
    if(color.lightness() >= 128)
        color = color.darker(60);
    else
        color = color.lighter(50);
    
    if (active)
        color.setAlpha(0);
    else
        color.setAlpha(mEditor->inactiveFadeAlpha());

    mBackgroundAnimation.stop();

    if (mEditor->isVisible())
    {
        mBackgroundAnimation.setDuration(500);
        mBackgroundAnimation.setEasingCurve( QEasingCurve::OutCubic );
        mBackgroundAnimation.setStartValue( backgroundColor() );
        mBackgroundAnimation.setEndValue( color );
        mBackgroundAnimation.start();
    }
    else
    {
        setBackgroundColor(color);
    }
}
开发者ID:8c6794b6,项目名称:supercollider,代码行数:28,代码来源:overlay.cpp

示例8: drawSelectionBackground

void ItemLibraryTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
    painter->save();
    QLinearGradient gradient;
    QColor highlight = option.palette.highlight().color();
    gradient.setColorAt(0, highlight.lighter(130));
    gradient.setColorAt(1, highlight.darker(130));
    gradient.setStart(option.rect.topLeft());
    gradient.setFinalStop(option.rect.bottomLeft());
    painter->fillRect(option.rect, gradient);
    painter->setPen(highlight.lighter());
    painter->drawLine(option.rect.topLeft(),option.rect.topRight());
    painter->setPen(highlight.darker());
    painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
    painter->restore();
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:16,代码来源:itemlibrarytreeview.cpp

示例9: setBackground

void caScriptButton::setBackground(QColor c)
{
    thisBackColor = c;
    thisHoverColor = c.lighter(120);
    thisBorderColor = c.darker(150);
    setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor);
}
开发者ID:caqtdm,项目名称:caqtdm,代码行数:7,代码来源:cascriptbutton.cpp

示例10: paintEvent

//! [5]
void VibrationSurface::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QRect rect = geometry();
    int dx = 0, dy = 0;

    if (height() > width()) {
        dy = height() / NumberOfLevels;
        rect.setHeight(dy);
    } else {
        dx = width() / NumberOfLevels;
        rect.setWidth(dx);
    }
//! [5]
//! [6] 
    for (int i = 0; i < NumberOfLevels; i++) {
        int x = i * dx;
        int y = i * dy;
        int intensity = getIntensity(x, y);
        QColor color = QColor(40, 80, 10).lighter(100 + intensity);

        rect.moveTo(x, y);
        painter.fillRect(rect, color);
        painter.setPen(color.darker());
        painter.drawText(rect, Qt::AlignCenter, QString::number(intensity));
    }
}
开发者ID:bailsoftware,项目名称:qt-embedded,代码行数:28,代码来源:vibrationsurface.cpp

示例11: paint

void TargetSelectorDelegate::paint(QPainter *painter,
                                   const QStyleOptionViewItem &option,
                                   const QModelIndex &) const
{
    painter->save();
    painter->setClipping(false);

    if (selectionGradient.isNull())
        selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png"));

    if (option.state & QStyle::State_Selected) {
        QColor color =(option.state & QStyle::State_HasFocus) ?
                      option.palette.highlight().color() :
                      option.palette.dark().color();
        painter->fillRect(option.rect, color.darker(140));
        Utils::StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5);
        painter->setPen(QColor(255, 255, 255, 60));
        painter->drawLine(option.rect.topLeft(), option.rect.topRight());
        painter->setPen(QColor(255, 255, 255, 30));
        painter->drawLine(option.rect.bottomLeft() - QPoint(0,1), option.rect.bottomRight() -  QPoint(0,1));
        painter->setPen(QColor(0, 0, 0, 80));
        painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
    }
    painter->restore();
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:25,代码来源:miniprojecttargetselector.cpp

示例12:

void
BinClockWidget::setColor(int i, QColor & c)
{
    palettes[i].setColor(QPalette::Background, c);
    palettes[i].setColor(QPalette::Light, c.lighter());
    palettes[i].setColor(QPalette::QPalette::Dark, c.darker());
}
开发者ID:BGCX261,项目名称:zoclock-svn-to-git,代码行数:7,代码来源:zocwidget.cpp

示例13: setAppearance

void Peg::setAppearance(const QColor& color)
{
	QRadialGradient gradient(QPointF(10,10), 10, QPoint(10,13));
	gradient.setColorAt(0, color);
	gradient.setColorAt(1, color.darker());
	setBrush(gradient);
}
开发者ID:gottcode,项目名称:peg-e,代码行数:7,代码来源:peg.cpp

示例14: paintEvent

void LocationBar::paintEvent(QPaintEvent *event)
{
    QPalette p = palette();
    QColor defaultBaseColor = QApplication::palette().color(QPalette::Base);
    QColor backgroundColor = defaultBaseColor;
    if (m_webView && m_webView->url().scheme() == QLatin1String("https")
        && p.color(QPalette::Text).value() < 128) {
        QColor lightYellow(248, 248, 210);
        backgroundColor = lightYellow;
    }

    // set the progress bar
    if (m_webView) {
        int progress = m_webView->progress();
        if (progress == 0) {
            p.setBrush(QPalette::Base, backgroundColor);
        } else {
            QColor loadingColor = QColor(116, 192, 250);
            if (p.color(QPalette::Text).value() >= 128)
                loadingColor = defaultBaseColor.darker(200);

            QLinearGradient gradient(0, 0, width(), 0);
            gradient.setColorAt(0, loadingColor);
            gradient.setColorAt(((double)progress)/100, backgroundColor);
            p.setBrush(QPalette::Base, gradient);
        }
        setPalette(p);
    }

    LineEdit::paintEvent(event);
}
开发者ID:3dfxmadscientist,项目名称:arora,代码行数:31,代码来源:locationbar.cpp

示例15: setBackground

void caMessageButton::setBackground(QColor c)
{
    thisBackColor = c;
    thisHoverColor = c.lighter(120);
    thisBorderColor = c.darker(150);
    setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor, thisDisabledForeColor);
}
开发者ID:rorydog1,项目名称:epics,代码行数:7,代码来源:camessagebutton.cpp


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