本文整理汇总了C++中QBrush::setStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ QBrush::setStyle方法的具体用法?C++ QBrush::setStyle怎么用?C++ QBrush::setStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBrush
的用法示例。
在下文中一共展示了QBrush::setStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOwner
void Hex::setOwner(QString player){
// set the owner
owner = player;
// change the color
if (player == QString("NOONE")){
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::lightGray);
setBrush(brush);
}
if (player == QString("PLAYER1")){
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::blue);
setBrush(brush);
}
if (player == QString("PLAYER2")){
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::red);
setBrush(brush);
}
}
示例2:
void KnotRendererBatch::PaintInterfaceData::set(int fillColour, int outlineColour, int outlineWidth, const QList< QColor > colorList)
{
QPen pen = p->pen();
pen.setWidth(outlineWidth);
if (outlineColour != -1)
pen.setColor(colorList[outlineColour]);
else
{
QBrush brush = pen.brush();
brush.setStyle(Qt::NoBrush);
pen.setBrush(brush);
}
p->setPen(pen);
QBrush brush = p->brush();
if (fillColour == -1)
{
brush.setStyle(Qt::NoBrush);
}
else
{
brush.setStyle(Qt::SolidPattern);
brush.setColor(colorList[fillColour]);
}
p->setBrush(brush);
}
示例3: paint
void QtArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setRenderHint(QPainter::Antialiasing);
if (this->isSelected())
{
const QColor color(255,0,0);
QPen pen;
pen.setColor(color);
pen.setWidth(3);
painter->setPen(pen);
QBrush brush;
brush.setColor(color);
brush.setStyle(Qt::SolidPattern);
painter->setBrush(brush);
}
else
{
const QColor color(0,0,0);
QPen pen;
pen.setColor(color);
pen.setWidth(1);
painter->setPen(pen);
QBrush brush;
brush.setColor(color);
brush.setStyle(Qt::SolidPattern);
painter->setBrush(brush);
}
painter->drawLine(this->line());
//The angle from tail to head
double angle = GetAngle(line().dx(),line().dy());
if (line().dy() >= 0.0) angle = (1.0 * M_PI) + angle;
const double sz = 10.0; //pixels
{
const QPointF p0 = this->line().p1();
const QPointF p1
= p0 + QPointF(
std::sin(angle + M_PI + (M_PI * 0.1)) * sz,
-std::cos(angle + M_PI + (M_PI * 0.1)) * sz);
const QPointF p2
= p0 + QPointF(
std::sin(angle + M_PI - (M_PI * 0.1)) * sz,
-std::cos(angle + M_PI - (M_PI * 0.1)) * sz);
painter->drawPolygon(QPolygonF() << p0 << p1 << p2);
}
{
const QPointF p0 = this->line().p2();
const QPointF p1
= p0 + QPointF(
std::sin(angle + 0.0 + (M_PI * 0.1)) * sz,
-std::cos(angle + 0.0 + (M_PI * 0.1)) * sz);
const QPointF p2
= p0 + QPointF(
std::sin(angle + 0.0 - (M_PI * 0.1)) * sz,
-std::cos(angle + 0.0 - (M_PI * 0.1)) * sz);
painter->drawPolygon(QPolygonF() << p0 << p1 << p2);
}
}
示例4: drawArrowHead
void QgsLayoutItemPolyline::drawArrowHead( QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth )
{
if ( !p )
return;
double angleRad = angle / 180.0 * M_PI;
QPointF middlePoint( x, y );
//rotate both arrow points
QPointF p1 = QPointF( -arrowHeadWidth / 2.0, arrowHeadWidth );
QPointF p2 = QPointF( arrowHeadWidth / 2.0, arrowHeadWidth );
QPointF p1Rotated, p2Rotated;
p1Rotated.setX( p1.x() * std::cos( angleRad ) + p1.y() * -std::sin( angleRad ) );
p1Rotated.setY( p1.x() * std::sin( angleRad ) + p1.y() * std::cos( angleRad ) );
p2Rotated.setX( p2.x() * std::cos( angleRad ) + p2.y() * -std::sin( angleRad ) );
p2Rotated.setY( p2.x() * std::sin( angleRad ) + p2.y() * std::cos( angleRad ) );
QPolygonF arrowHeadPoly;
arrowHeadPoly << middlePoint;
arrowHeadPoly << QPointF( middlePoint.x() + p1Rotated.x(), middlePoint.y() + p1Rotated.y() );
arrowHeadPoly << QPointF( middlePoint.x() + p2Rotated.x(), middlePoint.y() + p2Rotated.y() );
QPen arrowPen = p->pen();
arrowPen.setJoinStyle( Qt::RoundJoin );
QBrush arrowBrush = p->brush();
arrowBrush.setStyle( Qt::SolidPattern );
p->setPen( arrowPen );
p->setBrush( arrowBrush );
arrowBrush.setStyle( Qt::SolidPattern );
p->drawPolygon( arrowHeadPoly );
}
示例5: brush
QBrush FillTab::brush(QBrush b) const {
QColor this_color = colorDirty() ? color() : b.color();
Qt::BrushStyle this_style = styleDirty() ? style() : b.style();
if (useGradientDirty()) {
// Apply / unapply gradient
if (useGradient()) {
b = QBrush(gradient());
} else {
b.setColor(this_color);
b.setStyle(this_style);
}
} else {
// Leave gradient but make other changes.
QGradient this_gradient;
if (const QGradient *grad = b.gradient()) {
if (gradientDirty()) {
this_gradient = gradient();
} else {
this_gradient = *grad;
}
b = QBrush(this_gradient);
} else {
b.setColor(this_color);
b.setStyle(this_style);
}
}
return b;
}
示例6: drawReference
void VpGrid::drawReference(GridGC &gridGC)
{
int x,y;
VpGC *vpgc = gridGC.m_gc;
QPainter *gc = vpgc->getGC();
// Assuming QPainter has already established begin().
gc->setRenderHint(QPainter::Antialiasing, true);
if (m_referenceStyle == VpGrid::REFSTYLE_SQUARE)
{
// Set the pen.
QPen pen;
pen.setStyle(Qt::NoPen);
gc->setPen(pen);
// Set the brush.
QBrush brush;
brush.setColor(m_referenceColor);
brush.setStyle(Qt::SolidPattern);
gc->setBrush(brush);
QRectF origin;
origin.setLeft(-1.5 + m_xAlignment);
origin.setRight(1.5 + m_xAlignment);
origin.setBottom(-1.5 + m_yAlignment);
origin.setTop(1.5 + m_yAlignment);
gc->drawRect(origin);
} else if (m_referenceStyle == VpGrid::REFSTYLE_CIRCLE)
{
// Set the pen.
QPen pen;
pen.setStyle(Qt::NoPen);
gc->setPen(pen);
// Set the brush.
QBrush brush;
brush.setColor(m_referenceColor);
brush.setStyle(Qt::SolidPattern);
gc->setBrush(brush);
gc->drawEllipse(QPoint(m_xAlignment, m_yAlignment), 2, 2);
} else
{
// Set the pen, no brush.
QPen pen;
pen.setColor(m_referenceColor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(2);
gc->setPen(pen);
// Create a 'X' pattern.
QLineF cross[2];
cross[0].setLine(-1.5 + m_xAlignment, -1.5 + m_yAlignment, 1.5 + m_xAlignment, 1.5 + m_yAlignment);
cross[1].setLine(-1.5 + m_xAlignment, 1.5 + m_yAlignment, 1.5 + m_xAlignment, -1.5 + m_yAlignment);
gc->drawLines(cross, 2);
}
//delete gc;
}
示例7: paintEvent
void Tab::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(backgroundColor());
painter.setOpacity(1);
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
painter.drawRect(rect());
paintHalo(&painter);
QStylePainter style(this);
if (!icon().isNull()) {
style.translate(0, 12);
}
QStyleOptionButton option;
initStyleOption(&option);
option.features |= QStyleOptionButton::Flat;
option.iconSize = QSize(-1, -1); // Prevent icon from being drawn twice
style.drawControl(QStyle::CE_PushButtonLabel, option);
if (!icon().isNull()) {
const QSize &size = iconSize();
QRect iconRect(QPoint((width()-size.width())/2, 0), size);
icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal);
}
if (!_active) {
QColor overlayColor = backgroundColor();
overlayColor.setAlphaF(0.36);
QBrush overlay;
overlay.setStyle(Qt::SolidPattern);
overlay.setColor(overlayColor);
painter.fillRect(rect(), overlay);
}
#ifdef DEBUG_LAYOUT
QPainter debug(this);
QPen pen;
pen.setColor(Qt::red);
pen.setWidth(2);
debug.setPen(pen);
debug.setBrush(Qt::NoBrush);
debug.drawRect(rect());
#endif
}
示例8: loadOdf
void KoSectionStyle::loadOdf(const KoXmlElement *element, KoOdfLoadingContext &context)
{
if (element->hasAttributeNS(KoXmlNS::style, "display-name"))
d->name = element->attributeNS(KoXmlNS::style, "display-name", QString());
if (d->name.isEmpty()) // if no style:display-name is given us the style:name
d->name = element->attributeNS(KoXmlNS::style, "name", QString());
context.styleStack().save();
// Load all parents - only because we don't support inheritance.
QString family = element->attributeNS(KoXmlNS::style, "family", "section");
context.addStyles(element, family.toLocal8Bit().constData()); // Load all parents - only because we don't support inheritance.
context.styleStack().setTypeProperties("section"); // load all style attributes from "style:section-properties"
KoStyleStack &styleStack = context.styleStack();
// in 1.6 this was defined at KoParagLayout::loadOasisParagLayout(KoParagLayout&, KoOasisContext&)
if (styleStack.hasProperty(KoXmlNS::style, "writing-mode")) { // http://www.w3.org/TR/2004/WD-xsl11-20041216/#writing-mode
QString writingMode = styleStack.property(KoXmlNS::style, "writing-mode");
setTextProgressionDirection(KoText::directionFromString(writingMode));
}
// Indentation (margin)
bool hasMarginLeft = styleStack.hasProperty(KoXmlNS::fo, "margin-left");
bool hasMarginRight = styleStack.hasProperty(KoXmlNS::fo, "margin-right");
if (hasMarginLeft)
setLeftMargin(KoUnit::parseValue(styleStack.property(KoXmlNS::fo, "margin-left")));
if (hasMarginRight)
setRightMargin(KoUnit::parseValue(styleStack.property(KoXmlNS::fo, "margin-right")));
// The fo:background-color attribute specifies the background color of a paragraph.
if (styleStack.hasProperty(KoXmlNS::fo, "background-color")) {
const QString bgcolor = styleStack.property(KoXmlNS::fo, "background-color");
QBrush brush = background();
if (bgcolor == "transparent")
brush.setStyle(Qt::NoBrush);
else {
if (brush.style() == Qt::NoBrush)
brush.setStyle(Qt::SolidPattern);
brush.setColor(bgcolor); // #rrggbb format
}
setBackground(brush);
}
styleStack.restore();
}
示例9: hoverLeaveEvent
void Button::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
// change color to dark cyan
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::darkCyan);
setBrush(brush);
}
示例10: paintEvent
void AssetDecodePopup::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
//style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
itemMutex.lock();
QBrush brush;
brush.setColor(QColor(51, 51, 51));
brush.setStyle(Qt::BrushStyle::SolidPattern);
p.fillRect(0, 0, width(), height(), brush);
QPen pen;
pen.setColor(QColor(41, 41, 41));
p.setPen(pen);
p.drawRect(0, 0, width()-1, height()-1);
int yPos = 2;
for (const auto& item : m_items)
{
drawItem(item.displayFilename, item.status, QRect(2, yPos, width() - 5, SingleItemHeight), item.progress);
yPos += SingleItemHeight;
}
itemMutex.unlock();
}
示例11: DrawText
void pigalePaint::DrawText(QPainter *p,Tpoint &a,tvertex v,int col,int center)
// draw text centered at a, with a surrounding rectangle
// center=1 center
// center=0 horizontal
{QString t = getVertexLabel(GCP,v);
QPen pn = p->pen();pn.setWidth(1);pn.setColor(color[Black]);p->setPen(pn);
QSize size = QFontMetrics(p->font()).size(Qt::AlignCenter,t);
double nx = size.width() + 4; double ny = size.height();
if(t.length() == 0)nx = ny= 8;
QRect rect;
//if pn.setWidth() > 1 => rect increase
if(center)
rect = QRect((int)(to_x(a.x())-nx/2+.5),(int)(to_y(a.y())-ny/2+.5),(int)(nx+.5),(int)(ny+.5));
else
rect = QRect((int)(to_x(a.x())-nx/2+.5),(int)(to_y(a.y())-ny+1.),(int)(nx+.5),(int)(ny+.5));
QBrush pb = p->brush();
pb.setStyle(Qt::SolidPattern);
pb.setColor(color[bound(col,0,16)]);
//pb.setColor(color[White]);
p->setBrush(pb);
//pn.setColor(color[col]);pn.setWidth(1);p->setPen(pn);
pn.setWidth(1);pn.setColor(color[Black]);p->setPen(pn);
p->drawRect(rect);
if(ny < 6)return;
p->drawText(rect,Qt::AlignCenter,t);
}
示例12: setEdgeRects
void Draw_Arc::setEdgeRects()
{
QBrush rectbrush;
rectbrush.setColor(QColor(0,175,225));
rectbrush.setStyle(Qt::SolidPattern);
qDebug()<<"strt pnt "<<StrtPnt<<" "<<"end pnt "<<EndPnt<<"\n";
Strt_Rect = new QGraphicsRectItem(QRectF(QPointF(StrtPnt.x()-5.0,StrtPnt.y()-5.0),QPointF(StrtPnt.x()+5.0,StrtPnt.y()+5.0)));
Strt_Rect->setBrush(rectbrush);
End_Rect = new QGraphicsRectItem(QRectF(QPointF(EndPnt.x()-5.0,EndPnt.y()-5.0),QPointF(EndPnt.x()+5.0,EndPnt.y()+5.0)));
End_Rect->setBrush(rectbrush);
Curve_Rect = new QGraphicsRectItem(QRectF(QPointF(CurvePnt.x()-5.0,CurvePnt.y()-5.0),QPointF(CurvePnt.x()+5.0,CurvePnt.y()+5.0)));
Curve_Rect->setBrush(rectbrush);
QPen bound_rect;
bound_rect.setStyle(Qt::DashLine);
Bounding_Rect = new QGraphicsRectItem(QRectF(item->boundingRect().topLeft(),item->boundingRect().bottomRight()));
Bounding_Rect->setPen(bound_rect);
QPointF pnt1,pnt2;
pnt1.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)-5);
pnt1.setY(item->boundingRect().topLeft().y()-20);
pnt2.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)+5);
pnt2.setY(item->boundingRect().topLeft().y()-10);
Rot_Rect = new QGraphicsEllipseItem(QRectF(pnt1,pnt2));
Rot_Rect->setBrush(rectbrush);
}
示例13: paint
void CursorRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->save();
QBrush brush;
int w = width();
int h = height();
brush.setColor(Qt::black);
brush.setStyle(Qt::SolidPattern);
painter->setPen(Qt::NoPen);
painter->setBrush(brush);
painter->drawRect(0,0,w,h);
int beatLength = 120 / _beatCount;
for(int i=0;i<w;i += 120)
{
painter->setPen(Qt::lightGray);
painter->drawLine(i,0,i,h-4);
for(int j=1;j<_beatCount;++j)
{
painter->setPen(Qt::darkGray);
painter->drawLine(i+j*beatLength,0,i+j*beatLength,h-8);
}
}
painter->restore();
}
示例14: paintEvent
void Dialog::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
// make our polygon
QPolygon poly;
poly << QPoint(10, 10);
poly << QPoint(10, 100);
poly << QPoint(100, 10);
poly << QPoint(100, 100);
// make a pen
QPen linePen;
linePen.setWidth(8);
linePen.setColor(Qt::red);
//linePen.setJoinStyle(Qt::RoundJoin);
linePen.setJoinStyle(Qt::MiterJoin);
linePen.setStyle(Qt::DotLine);
painter.setPen(linePen);
// make a brush
QBrush fillBrush;
fillBrush.setColor(Qt::green);
fillBrush.setStyle(Qt::SolidPattern);
// fill the polygon
QPainterPath path;
path.addPolygon(poly);
painter.fillPath(path, fillBrush);
// draw polygon
painter.drawPolygon(poly);
}
示例15: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// -----------------------------------------------------------------------
ui->setupUi(this);
QGraphicsScene *scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
// -----------------------------------------------------------------------
// kolor pedzla
QBrush brush = QBrush(Qt::red);
brush.setStyle(Qt::DiagCrossPattern);
// tworzymy obiekts
QGraphicsRectItem *rect = new QGraphicsRectItem(10, 10, 90, 90);
rect->setBrush(brush);
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// definiujemy czas trwania animacji
QTimeLine *timeLine = new QTimeLine(1000);
timeLine->setFrameRange(0, 100);
// definiujemy animacje
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation();
animation->setItem(rect);
animation->setTimeLine(timeLine);
// animacja
int odcinek = 100;
for (int i = 0; i < 100; ++i)
animation->setPosAt(i / 100.0, QPointF(i, i));
// uruchamiamy scenę i animację
scene->addItem(rect);
timeLine->start();
}