本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
}