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


C++ QBrush::setColor方法代码示例

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


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

示例1: indexMapQBrushTest

void FormatMapTest::indexMapQBrushTest()
{
  IndexFormatMap map;
  QBrush brush;
  brush.setColor(QColor(10, 20, 30));
  map.setFormatForIndex(1, 2, brush);
  QVERIFY(map.formatForIndex(1, 1).isNull());
  QCOMPARE(map.formatForIndex(1, 2).value<QBrush>().color().red(), 10);
  QCOMPARE(map.formatForIndex(1, 2).value<QBrush>().color().green(), 20);
  QCOMPARE(map.formatForIndex(1, 2).value<QBrush>().color().blue(), 30);
}
开发者ID:scandyna,项目名称:multidiagtools,代码行数:11,代码来源:FormatMapTest.cpp

示例2: resize

void UmlCanvas::resize(CanvasFormat f)
{

    setSceneRect(0, 0,(int)(formatSize[f].w * zoom_value),
                     (int)(formatSize[f].h * zoom_value));
    width100percent = formatSize[f].w;
    height100percent = formatSize[f].h;
    update_limits();

    // force redisplay else phantoms may appears
    QBrush bBrush = backgroundBrush();
    bBrush.setColor(::Qt::lightGray);
    setBackgroundBrush(bBrush);
    //setBackgroundColor(::Qt::lightGray);
    update();
    bBrush.setColor(::Qt::white);
    //setBackgroundColor(::Qt::white);
    setBackgroundBrush(bBrush);
    update();
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:20,代码来源:UmlCanvas.cpp

示例3: setPenBrushDriftRect

void AbstractItem::setPenBrushDriftRect(QPainter* painter)
{
	QPen pen(QColor("whitesmoke"));
	pen.setStyle(Qt::SolidLine);
	pen.setWidth(0);
	QBrush brush;
	brush.setStyle(Qt::NoBrush);
	brush.setColor(Qt::white);
	painter->setPen(pen);
	painter->setBrush(brush);
}
开发者ID:Esenin,项目名称:qreal,代码行数:11,代码来源:abstractItem.cpp

示例4: rowColumnMapBaseQBrushTest

void FormatMapTest::rowColumnMapBaseQBrushTest()
{
  RowColumnFormatMapBase map;
  QBrush brush;
  brush.setColor(QColor(10, 20, 30));
  map.setFormatVariantForIndex(1, brush);
  QVERIFY(map.formatForIndex(0).isNull());
  QCOMPARE(map.formatForIndex(1).value<QBrush>().color().red(), 10);
  QCOMPARE(map.formatForIndex(1).value<QBrush>().color().green(), 20);
  QCOMPARE(map.formatForIndex(1).value<QBrush>().color().blue(), 30);
}
开发者ID:scandyna,项目名称:multidiagtools,代码行数:11,代码来源:FormatMapTest.cpp

示例5: paint

void CanvasRect::paint(QPainter *painter, const QTransform &tran, const QRectF &limits)
{
    QRectF plotRect = bounds();
    // Let's not waste time here...
    if (!limits.intersects(plotRect)) return;

    // TODO: This boilerplate style stuff to a CanvasShape::applyStyle(QPainter*) func?
    QPen pen;
    LineSpec *ln = lineSpec();
    pen.setColor(ln->color());
    pen.setWidthF(ln->width());

    QString style = ln->style();
    if (style == ".") {
        pen.setStyle(Qt::SolidLine);
    } else {
        pen.setStyle( LineSpec::styleMap[style] );
    }

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(fillSpec()->color());

    painter->setRenderHint(QPainter::Antialiasing);

    // Only draw the part of the rect in the view
    QRectF rect = limits.intersected(plotRect);
    // Figure out which sides still need lines...
    QVector<QLineF> lines;
    if (rect.left() == plotRect.left())
        lines << QLineF(rect.bottomLeft(), rect.topLeft());
    if (rect.right() == plotRect.right())
        lines << QLineF(rect.bottomRight(), rect.topRight());
    if (rect.top() == plotRect.top())
        lines << QLineF(rect.topLeft(), rect.topRight());
    if (rect.bottom() == plotRect.bottom())
        lines << QLineF(rect.bottomLeft(), rect.bottomRight());

    // Map the fill and lines
    QRectF mappedRect = tran.mapRect(rect);
    for (int i=0; i<lines.length(); ++i) {
        lines[i] = tran.map(lines[i]);
    }

    // Draw the rect
    painter->setPen(Qt::NoPen);
    painter->setBrush(brush);
    painter->drawRect(mappedRect);

    // Draw the outline
    painter->setBrush(Qt::NoBrush);
    painter->setPen(pen);
    painter->drawLines(lines);
}
开发者ID:pjmahoney,项目名称:nutmeg,代码行数:54,代码来源:canvasrect.cpp

示例6: awesomeHeaderBrush

static QBrush awesomeHeaderBrush()
{
    static QBrush brush;
    if (brush.style() == Qt::NoBrush) {
        QColor alphaBlue(Qt::darkBlue);
        alphaBlue.setAlpha(155);
        brush.setStyle(Qt::SolidPattern);
        brush.setColor(alphaBlue);
    }
    return brush;
}
开发者ID:jpleclerc,项目名称:Umbrello-ng2,代码行数:11,代码来源:classifierwidget.cpp

示例7: setActive

void ArrowSprite::setActive(bool value)
{
  int alpha = (value?128:64);
//   kDebug() << value << alpha;
  QBrush b = brush();
  QColor color = b.color();
  color.setAlpha(alpha);
//   kDebug() << color.alpha();
  b.setColor(color);
  setBrush(b);
}
开发者ID:KDE,项目名称:ksirk,代码行数:11,代码来源:arrowsprite.cpp

示例8: rect

void
TextField::DoPaint( const GUI::DrawContext& inDC,
                    RGBColor inTextColor,
                    RGBColor inBackgroundColor )
{
#if USE_QT

  QPainter* p = inDC.handle.painter;
  QRect rect(
    static_cast<int>( inDC.rect.left ),
    static_cast<int>( inDC.rect.top ),
    static_cast<int>( inDC.rect.right - inDC.rect.left ),
    static_cast<int>( inDC.rect.bottom - inDC.rect.top )
  );
  QBrush brush;
  brush.setStyle( Qt::SolidPattern );
  if( mColor != RGBColor( RGBColor::NullColor ) )
  {
    QColor backColor( mColor.R(), mColor.G(), mColor.B() );
    brush.setColor( backColor );
    p->fillRect( rect, brush );
  }

  QFont font;
  font.fromString( QString( "Arial" ) );
  font.setPixelSize( static_cast<int>( mTextHeight * ( inDC.rect.bottom - inDC.rect.top ) ) );
  font.setBold( true );
  QColor textColor( inTextColor.R(), inTextColor.G(), inTextColor.B() );
  QPen pen;
  brush.setColor( textColor );
  pen.setColor( textColor );
  p->setPen( pen );
  p->setBrush( brush );
  p->setFont( font );

  QString text = QString::fromLocal8Bit( mText.c_str() );
  text.append( " " ).prepend( " " );
  p->drawText( rect, Qt::AlignCenter, text );

#endif // USE_QT
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:41,代码来源:TextField.cpp

示例9: drawEdges

void Draw_Line::drawEdges()
{
   QBrush rectbrush;
   rectbrush.setColor(QColor(0,175,225));
   rectbrush.setStyle(Qt::SolidPattern);
   for(int i=0;i<poly_pnts.size();i++)
   {
       QGraphicsRectItem *rect = new QGraphicsRectItem(QRectF(QPointF(poly_pnts[i].x()-5.0,poly_pnts[i].y()-5.0),QPointF(poly_pnts[i].x()+5.0,poly_pnts[i].y()+5.0)));
       rect->setBrush(rectbrush);
       edge_items.push_back(rect);
   }
}
开发者ID:OpenModelica,项目名称:OMNotebook,代码行数:12,代码来源:Draw_line.cpp

示例10: setInProcessState

void instDialog::setInProcessState(QTreeWidgetItem *item)
{
    QBrush b = item->foreground(1);
    b.setColor(Qt::black);
    item->setForeground(1,b);
    item->setForeground(0,b);

    QFont f = item->font(1);
    f.setBold(true);
    item->setFont(1,f);
    item->setFont(0,f);
}
开发者ID:UNINETT,项目名称:fwbuilder,代码行数:12,代码来源:instDialog_ui_ops.cpp

示例11: setWarningState

void instDialog::setWarningState(QTreeWidgetItem *item)
{
    QBrush b = item->foreground(1);
    b.setColor(QColor("orange"));
    item->setForeground(1,b);
    item->setForeground(0,b);

    QFont f = item->font(1);
    f.setBold(true);
    item->setFont(1,f);
    item->setFont(0,f);
}
开发者ID:UNINETT,项目名称:fwbuilder,代码行数:12,代码来源:instDialog_ui_ops.cpp

示例12: setErrorState

void instDialog::setErrorState(QTreeWidgetItem *item)
{
    QBrush b = item->foreground(1);
    b.setColor(Qt::darkRed);
    item->setForeground(1,b);
    item->setForeground(0,b);

    QFont f = item->font(1);
    f.setBold(true);
    item->setFont(1,f);
    item->setFont(0,f);
}
开发者ID:UNINETT,项目名称:fwbuilder,代码行数:12,代码来源:instDialog_ui_ops.cpp

示例13: fill

/// Fills the specified cell.
///
/// Marks it filled in the pathingMap_ and draws a gray square to visually
/// represent it.
void Game::fill( int x,  int y){
    pathingMap_.fillCell(x,y);

    // draw rectangle
    QGraphicsRectItem* rect = new QGraphicsRectItem(0,0,cellSize_,cellSize_);
    rect->setPos(x*cellSize_,y*cellSize_);
    QBrush brush;
    brush.setColor(Qt::gray);
    brush.setStyle(Qt::SolidPattern);
    rect->setBrush(brush);
    scene_->addItem(rect);
}
开发者ID:MeLikeyCode,项目名称:PacmanPathfindingDemo,代码行数:16,代码来源:Game.cpp

示例14: paintEvent

void OptionsMenu::paintEvent(QPaintEvent * event )
{
    QPainter painter(this);
    QPen* pen = new QPen();
    pen->setWidth(4);
    painter.setPen(*pen);
    QBrush* brush = new QBrush(Qt::Dense5Pattern);
    brush->setColor(QColor(48,213,208));
    painter.setBrush(*brush);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.drawRoundedRect(1,1,this->width()-2,this->height()-2,20,10);
}
开发者ID:Danmerpro,项目名称:Simulator,代码行数:12,代码来源:optionsmenu.cpp

示例15: draw

 // функция отрисовки корабля
void Ship::draw(QPainter *painter)
{
    QPen pen; // карандаш(определяет контур фигур)
    QBrush brush; // кисть(определяет заливку фигур)
    if(conflicted) // корабль конфликтный
    {
        drawShadow(painter); // рисуем "тень"
        brush.setColor(Qt::red); // выбираем цвет заливки
    }
    else if(active) // корабль не конфликтный, но активный
    {
        drawShadow(painter); // рисуем "тень"
        brush.setColor(Qt::green); // выбираем цвет заливки
    }
    else
    {
        brush.setColor(Qt::blue); // выбираем цвет заливки
    }
    brush.setStyle(Qt::SolidPattern); // определяем стиль закраски фигур (SolidPattern - сплошная закраска)
    pen.setWidth(2); // устанавливаем толщину карандаша
    if(active)
        pen.setColor(Qt::darkGreen); // выбираем цвет заливки
    else
        pen.setColor(Qt::gray); // выбираем цвет заливки
    painter->setPen(pen); // передаем карандаш рисовальщику
    painter->setBrush(brush); // передаем кисть рисовальщику
    // отрисовываем все "квадраты" корабля в зависимости от его ориентации
    for(int i = 0 ; i < size ; i++)
    {
        switch(dir)
        {
        case HORIZONTAL:
            painter->drawRect(i * CELL + drawPoint.x(), drawPoint.y(), CELL, CELL);
            break;
        case VERTICAL:
            painter->drawRect(drawPoint.x(), i * CELL + drawPoint.y(), CELL, CELL);
            break;
        }
    }
}
开发者ID:dashashlv,项目名称:kursovaja,代码行数:41,代码来源:ship.cpp


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