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


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

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


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

示例1: brush

QBrush StateEffects::brush(const QBrush& foreground, const QBrush& background) const {
      QColor color = foreground.color(); // TODO - actually work on brushes
      QColor bg = background.color();
      // Apply the foreground effects
      switch (_effects[Contrast]) {
            case ContrastFade:
                  color = ColorUtils::mix(color, bg, _amount[Contrast]);
                  break;
            case ContrastTint:
                  color = ColorUtils::tint(color, bg, _amount[Contrast]);
                  break;
            }
      // Now apply global effects
      return brush(color);
      }
开发者ID:BlueMockingbird,项目名称:MuseScore,代码行数:15,代码来源:colorscheme.cpp

示例2: paintAreas

void paintAreas( AbstractDiagram::Private* diagramPrivate, PaintContext* ctx, const QModelIndex& index,
                 const QList< QPolygonF >& areas, uint opacity )
{
    AbstractDiagram* diagram = diagramPrivate->diagram;
    QPainterPath path;
    for ( int i = 0; i < areas.count(); ++i )
    {
        const QPolygonF& p = areas[ i ];
        path.addPolygon( p );
        diagramPrivate->reverseMapper.addPolygon( index.row(), index.column(), p );
        path.closeSubpath();
    }

    ThreeDLineAttributes threeDAttrs = threeDLineAttributes( diagram, index );
    QBrush trans = diagram->brush( index );
    if ( threeDAttrs.isEnabled() ) {
        trans = threeDAttrs.threeDBrush( trans, path.boundingRect() );
    }
    QColor transColor = trans.color();
    transColor.setAlpha( opacity );
    trans.setColor(transColor);
    QPen indexPen = diagram->pen(index);
    indexPen.setBrush( trans );
    const PainterSaver painterSaver( ctx->painter() );

    ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() );
    ctx->painter()->setPen( PrintingParameters::scalePen( indexPen ) );
    ctx->painter()->setBrush( trans );

    ctx->painter()->drawPath( path );
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:31,代码来源:PaintingHelpers_p.cpp

示例3: painterSaver

/**
 * Draws an ordinary line in 3D by expanding it in the z-axis by the given depth.
 *
 * @param line The line to draw
 * @param brush The brush to fill the resulting polygon with
 * @param pen The pen to paint the borders of the resulting polygon with
 * @param props The 3D properties to draw the line with
 * @return The 3D shape drawn
 */
QPolygonF StockDiagram::Private::ThreeDPainter::drawThreeDLine( const QLineF &line, const QBrush &brush,
                                                                const QPen &pen, const ThreeDProperties &props )
{
    // Restores the painting properties when destroyed
    PainterSaver painterSaver( painter );

    const QPointF p1 = line.p1();
    const QPointF p2 = line.p2();

    // Project the 2D points of the line in 3D
    const QPointF deepP1 = projectPoint( p1, props.depth, props.angle );
    const QPointF deepP2 = projectPoint( p2, props.depth, props.angle );

    // The result is a 3D representation of the 2D line
    QPolygonF threeDArea;
    threeDArea << p1 << p2 << deepP2 << deepP1 << p1;

    // Use shadow colors if ThreeDProperties::useShadowColors is set
    // Note: Setting a new color on a brush or pen does not effect gradients or textures
    if ( props.useShadowColors ) {
        QBrush shadowBrush( brush );
        QPen shadowPen( pen );
        shadowBrush.setColor( calcShadowColor( brush.color(), props.angle ) );
        shadowPen.setColor( calcShadowColor( pen.color(), props.angle ) );
        painter->setBrush( shadowBrush );
        painter->setPen( shadowPen );
    } else {
        painter->setBrush( brush );
        painter->setPen( pen );
    }

    painter->drawPolygon( threeDArea );

    return threeDArea;
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:44,代码来源:KDChartStockDiagram_p.cpp

示例4: top

void MythD3D9Painter::DrawRect(const QRect &area, const QBrush &fillBrush,
                               const QPen &linePen, int alpha)
{
    int style = fillBrush.style();
    if (style == Qt::SolidPattern || style == Qt::NoBrush)
    {
        if (!m_render)
            return;

        if (style != Qt::NoBrush)
            m_render->DrawRect(area, fillBrush.color(), alpha);

        if (linePen.style() != Qt::NoPen)
        {
            int lineWidth = linePen.width();
            QRect top(QPoint(area.x(), area.y()),
                      QSize(area.width(), lineWidth));
            QRect bot(QPoint(area.x(), area.y() + area.height() - lineWidth),
                      QSize(area.width(), lineWidth));
            QRect left(QPoint(area.x(), area.y()),
                       QSize(lineWidth, area.height()));
            QRect right(QPoint(area.x() + area.width() - lineWidth, area.y()),
                        QSize(lineWidth, area.height()));
            m_render->DrawRect(top,   linePen.color(), alpha);
            m_render->DrawRect(bot,   linePen.color(), alpha);
            m_render->DrawRect(left,  linePen.color(), alpha);
            m_render->DrawRect(right, linePen.color(), alpha);
        }
        return;
    }

    MythPainter::DrawRect(area, fillBrush, linePen, alpha);
}
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:33,代码来源:mythpainter_d3d9.cpp

示例5: polish

void NorwegianWoodStyle::polish(QPalette &palette)
{
    QColor brown(212, 140, 95);
    QColor beige(212, 140, 95);
    QColor slightlyOpaqueBlack(0, 0, 0, 63);
    
    QPixmap backgroundIamge(":/images/woodbackground.png");
    QPixmap buttonImage(":/images/woodbutton.png");
    QPixmap midImage = buttonImage;
    
    QPainter painter;
    painter.begin(&midImage);
    painter.setPen(Qt::NoPen);
    painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
    painter.end();

    palette = QPalette(brown);
    
    palette.setBrush(QPalette::BrightText, Qt::white);
    palette.setBrush(QPalette::Base, beige);
    palette.setBrush(QPalette::Highlight, Qt::darkGreen);
    setTexture(palette, QPalette::Button, buttonImage); 
    setTexture(palette, QPalette::Mid, midImage); 
    setTexture(palette, QPalette::Window, backgroundIamge); 

    QBrush brush = palette.background();
    brush.setColor(brush.color().dark());

    palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
    palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
}
开发者ID:panweiping3,项目名称:programming,代码行数:35,代码来源:norwegianwoodstyle.cpp

示例6: image

static QWidget *qwtBackgroundWidget( QWidget *w )
{
    if ( w->parentWidget() == NULL )
        return w;

    if ( w->autoFillBackground() )
    {
        const QBrush brush = w->palette().brush( w->backgroundRole() );
        if ( brush.color().alpha() > 0 )
            return w;
    }

    if ( w->testAttribute( Qt::WA_StyledBackground ) )
    {
        QImage image( 1, 1, QImage::Format_ARGB32 );
        image.fill( Qt::transparent );

        QPainter painter( &image );
        painter.translate( -w->rect().center() );
        qwtDrawStyledBackground( w, &painter );
        painter.end();

        if ( qAlpha( image.pixel( 0, 0 ) ) != 0 )
            return w;
    }

    return qwtBackgroundWidget( w->parentWidget() );
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:28,代码来源:qwt_plot_canvas.cpp

示例7: paint

void IndexGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *)
{
	Q_UNUSED(options);
	if(isSilenced()) {
		QPen pen = _pen;
		pen.setStyle(Qt::DashDotDotLine);
		painter->setPen(pen);

		QBrush brush = _brush;
		QColor color = brush.color();
		color.setAlphaF(0.5);
		brush.setColor(color);
		painter->setBrush(brush);
	} else {
		painter->setPen(_pen);
		painter->setBrush(_brush);
	}

	painter->drawRect(_rect);
	if(!_icon.isNull()) {
		if(isSilenced())
			painter->setOpacity(0.5);
		painter->drawPixmap(_rect.topLeft(), _icon);
	}
}
开发者ID:EvilKitty3,项目名称:Drawpile,代码行数:25,代码来源:indexgraphicsitem.cpp

示例8: defaultHeaderData

QVariant AttributesModel::defaultHeaderData ( int section, Qt::Orientation orientation, int role ) const
{
  // Default values if nothing else matches
  switch ( role ) {
  case Qt::DisplayRole:
      //TODO for KDChart 3.0: Change to "return QString::number( section+1 );"
      return QLatin1String( orientation == Qt::Vertical ?  "Series " : "Item " ) + QString::number( section ) ;

  case KDChart::DatasetBrushRole: {
      if ( paletteType() == PaletteTypeSubdued )
          return Palette::subduedPalette().getBrush( section );
      else if ( paletteType() == PaletteTypeRainbow )
          return Palette::rainbowPalette().getBrush( section );
      else if ( paletteType() == PaletteTypeDefault )
          return Palette::defaultPalette().getBrush( section );
      else
          qWarning("Unknown type of fallback palette!");
  } break;
  case KDChart::DatasetPenRole: {
      // default to the color set for the brush (or it's defaults)
      // but only if no per model override was set
      if ( !modelData( role ).isValid() ) {
          QBrush brush = qVariantValue<QBrush>( headerData( section, orientation, DatasetBrushRole ) );
          return QPen( brush.color() );
      }
  } break;
  default:
      break;
  }

  return QVariant();
}
开发者ID:KDE,项目名称:koffice-chartingshape,代码行数:32,代码来源:KDChartAttributesModel.cpp

示例9: QDialog

DesktopBackgroundDialog::DesktopBackgroundDialog(RazorSettings * cfg, int screen, QSize desktopSize, const QBrush & brush, QWidget * parent)
    : QDialog(parent),
      m_desktopSize(desktopSize),
      m_type(RazorWorkSpaceManager::BackgroundColor),
      m_config(cfg),
      m_screen(screen)
{
    setupUi(this);
    // center it to current desktop
    move(parent->geometry().center() - geometry().center());
    
    // read current wallpaper brush
    if (brush.texture().isNull())
    {
        m_color = brush.color();
        preview();
    }
    else
    {
        QPixmap p = brush.texture().scaled(previewLabel->size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
        previewLabel->setPixmap(p);
    }

    connect(colorButton, SIGNAL(clicked()),
            this, SLOT(colorButton_clicked()));
    connect(wallpaperButton, SIGNAL(clicked()),
            this, SLOT(wallpaperButton_clicked()));
    connect(systemButton, SIGNAL(clicked()),
            this, SLOT(systemButton_clicked()));
    connect(keepAspectCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(preview()));

    buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    keepAspectCheckBox->setEnabled(false);
}
开发者ID:berndhs,项目名称:razor-qt,代码行数:35,代码来源:desktopbackgrounddialog.cpp

示例10: polish

void CustomStyle::polish(QPalette &palette)
{
    QColor brown(Qt::white);
    QColor beige(Qt::transparent);
    QColor slightlyOpaqueBlack(0, 0, 0, 63);

//      QPainter painter;
//      painter.begin(&midImage);
//      painter.setPen(Qt::NoPen);
//      painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
//      painter.end();

    palette = QPalette(brown);

    palette.setBrush(QPalette::BrightText, Qt::white);
    palette.setBrush(QPalette::Base, beige);
    palette.setBrush(QPalette::Highlight, Qt::darkGreen);
    palette.setBrush(QPalette::Button, beige);
    palette.setBrush(QPalette::ButtonText, Qt::white);
    palette.setBrush(QPalette::Mid, beige);
//	 palette.setBrush(QPalette::Window, QColor(158, 202, 243));
    palette.setBrush(QPalette::Window, beige);

    QBrush brush = palette.background();
    brush.setColor(brush.color().dark());

    palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
    palette.setBrush(QPalette::Disabled, QPalette::ButtonText, Qt::gray);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
}
开发者ID:loveywm,项目名称:Hiway-v0.0.1,代码行数:33,代码来源:customstyle.cpp

示例11: writeBackgroundColor

void QTableModelWordMLWriter::writeBackgroundColor(QXmlStreamWriter & stream, const QBrush & b)
{
	if (b.style() != Qt::NoBrush){
		//stream.writeEmptyElement("w:color");
		stream.writeAttribute("w:fill", b.color().name());
	}
}
开发者ID:lit-uriy,项目名称:QAdvancedItemViews,代码行数:7,代码来源:qtablemodelwordmlwriter.cpp

示例12: hasChildren

bool QBrushPropertyItem::hasChildren()
{
   if (!m_childrenSet)
   {
      m_childrenSet = true;

      QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject()));

      QPropertyItem* width = new QPropertyItem(brush.color(), "Color", this);
      m_children.append(width);
      connect(width, SIGNAL(valueChanged(const QString&, const QVariant&)), this,
              SLOT(onChildItemValueChanged(const QString&, const QVariant&)));


      int index = staticQtMetaObject.indexOfEnumerator("BrushStyle");
      QMetaEnum enumeration = staticQtMetaObject.enumerator(index);
      QChildEnumPropertyItem* brushStyle = new QChildEnumPropertyItem((int)brush.style(), "Brush Style",enumeration , this);
      m_children.append(brushStyle);
      connect(brushStyle, SIGNAL(valueChanged(const QString&, const QVariant&)), this,
              SLOT(onChildItemValueChanged(const QString&, const QVariant&)));


      QChildImagePropertyItem* textureImage = new QChildImagePropertyItem(brush.texture(), "Texture", this);
      m_children.append(textureImage);
      connect(textureImage, SIGNAL(valueChanged(const QString&, const QVariant&)), this,
              SLOT(onChildItemValueChanged(const QString&, const QVariant&)));

      return true;
   }
开发者ID:calebbuahin,项目名称:QPropertyModel,代码行数:29,代码来源:qbrushpropertyitem.cpp

示例13: setChildValues

void QBrushPropertyItem::setChildValues()
{
   if (!m_isSettingChildren)
   {
      m_isSettingChildren = true;

      QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject()));

      for (int i = 0; i < m_children.count(); i++)
      {
         QPropertyItem* child = m_children[i];
         QString propertyName = child->name();
         QVariant tval;

         if (propertyName == "Color")
         {
            tval = brush.color();
         }
         else if (propertyName == "Brush Style")
         {
            tval = (int)brush.style();
         }
         else if (propertyName == "Texture")
         {
            tval = brush.texture();
         }

         m_model->setData(child->index(), tval);
      }


      m_isSettingChildren = false;
   }
}
开发者ID:calebbuahin,项目名称:QPropertyModel,代码行数:34,代码来源:qbrushpropertyitem.cpp

示例14: eventFilter

bool UIMain::eventFilter( QObject* object, QEvent* event )
{
    if ( object == qmtbInfos ) {
        if ( event->type() == QEvent::Paint ) {
            if ( qmtbInfos->queuedMessageWidget()->pendingMessageCount() > 0 ) {
                QPainter painter( qmtbInfos );
                QBrush brush;

                qmtbInfos->queuedMessageWidget()->currentMessageInformations( 0, &brush, 0 );

                painter.setRenderHint( QPainter::Antialiasing );
                painter.setPen( QPen( brush.color().darker( 150 ), 0.5 ) );
                painter.setBrush( brush );
                painter.drawRoundedRect( qmtbInfos->rect().adjusted( 10 -4, -9, -10 +4, -1 ), 9, 9 );

                return true;
            }
        }
    }
    else if ( object == lWiiTDB ) {
        if ( event->type() == QEvent::MouseButtonPress ) {
            QDesktopServices::openUrl( lWiiTDB->toolTip() );
        }
    }

    return QMainWindow::eventFilter( object, event );
}
开发者ID:davidmattson1,项目名称:qwbfsmanager,代码行数:27,代码来源:UIMain.cpp

示例15: draw

/*!
  \brief Draw an intervall of the curve
  \param painter Painter
  \param xMap maps x-values into pixel coordinates.
  \param yMap maps y-values into pixel coordinates.
  \param from index of the first point to be painted
  \param to index of the last point to be painted. If to < 0 the 
         curve will be painted to its last point.

  \sa QwtCurve::drawCurve, QwtCurve::drawDots,
      QwtCurve::drawLines, QwtCurve::drawSpline,
      QwtCurve::drawSteps, QwtCurve::drawSticks
*/
void QwtCurve::draw(QPainter *painter,
    const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to)
{
    if ( !painter || dataSize() <= 0 )
        return;

    if (to < 0)
        to = dataSize() - 1;

    if ( verifyRange(from, to) > 0 )
    {
        painter->save();
        painter->setPen(d_pen);

        QBrush b = d_brush;
        if ( b.style() != Qt::NoBrush && !b.color().isValid() )
            b.setColor(d_pen.color());

        painter->setBrush(b);

        drawCurve(painter, d_style, xMap, yMap, from, to);
        painter->restore();

        if (d_sym.style() != QwtSymbol::None)
        {
            painter->save();
            drawSymbols(painter, d_sym, xMap, yMap, from, to);
            painter->restore();
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:44,代码来源:qwt_curve.cpp


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