本文整理汇总了C++中QBrush::style方法的典型用法代码示例。如果您正苦于以下问题:C++ QBrush::style方法的具体用法?C++ QBrush::style怎么用?C++ QBrush::style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBrush
的用法示例。
在下文中一共展示了QBrush::style方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applySettings
void PostWindow::applySettings(Settings::Manager * settings)
{
int scrollback = settings->value("IDE/postWindow/scrollback").toInt();
QFont font = settings->codeFont();
QPalette palette;
settings->beginGroup("IDE/editor/colors");
if (settings->contains("text")) {
QTextCharFormat format = settings->value("text").value<QTextCharFormat>();
QBrush bg = format.background();
QBrush fg = format.foreground();
if (bg.style() != Qt::NoBrush)
palette.setBrush(QPalette::Base, bg);
if (fg.style() != Qt::NoBrush)
palette.setBrush(QPalette::Text, fg);
}
settings->endGroup(); // colors
bool lineWrap = settings->value("IDE/postWindow/lineWrap").toBool();
setMaximumBlockCount(scrollback);
setFont(font);
setPalette(palette);
setLineWrap( lineWrap );
}
示例2: applySettings
void PostWindow::applySettings(Settings::Manager * settings)
{
int scrollback = settings->value("IDE/postWindow/scrollback").toInt();
QFont font = settings->codeFont();
QPalette palette;
settings->beginGroup("IDE/editor/colors");
if (settings->contains("text")) {
QTextCharFormat format = settings->value("text").value<QTextCharFormat>();
QBrush bg = format.background();
QBrush fg = format.foreground();
if (bg.style() != Qt::NoBrush)
palette.setBrush(QPalette::Base, bg);
if (fg.style() != Qt::NoBrush)
palette.setBrush(QPalette::Text, fg);
}
settings->endGroup(); // colors
bool lineWrap = settings->value("IDE/postWindow/lineWrap").toBool();
setMaximumBlockCount(scrollback);
setFont(font);
setPalette(palette);
setLineWrap( lineWrap );
QFontMetrics metrics (font);
QString stringOfSpaces (settings->value("IDE/editor/indentWidth").toInt(), QChar(' '));
setTabStopWidth(metrics.width(stringOfSpaces));
updateActionShortcuts(settings);
}
示例3: saveCurveLayout
QString PlotCurve::saveCurveLayout()
{
Plot *plot = static_cast<Plot *>(this->plot());
Graph *g = static_cast<Graph *>(plot->parent());
int index = g->curveIndex(static_cast<QwtPlotCurve *>(this));
int style = g->curveType(index);
QString s = "<Style>" + QString::number(style) + "</Style>\n";
if (style == Graph::Spline)
s += "<LineStyle>5</LineStyle>\n";
else if (style == Graph::VerticalSteps)
s += "<LineStyle>6</LineStyle>\n";
else
s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n";
QPen pen = this->pen();
if (pen.style() != Qt::NoPen){
s += "<Pen>\n";
s += "\t<Color>" + pen.color().name() + "</Color>\n";
s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n";
s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n";
s += "</Pen>\n";
}
QBrush brush = this->brush();
if (brush.style() != Qt::NoBrush){
s += "<Brush>\n";
s += "\t<Color>" + brush.color().name() + "</Color>\n";
s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n";
s += "</Brush>\n";
}
const QwtSymbol symbol = this->symbol();
if (symbol.style() != QwtSymbol::NoSymbol){
s += "<Symbol>\n";
s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n";
s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n";
s += "\t<SymbolPen>\n";
s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n";
s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n";
s += "\t</SymbolPen>\n";
brush = this->brush();
if (brush.style() != Qt::NoBrush){
s += "\t<SymbolBrush>\n";
s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n";
s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n";
s += "\t</SymbolBrush>\n";
}
s += "</Symbol>\n";
}
s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n";
s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n";
s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n";
return s;
}
示例4: updateBackground
void QJsonPaintEngine::updateBackground(Qt::BGMode bgMode, const QBrush &bgBrush)
{
Q_D(QJsonPaintEngine);
#ifdef QT_PICTURE_DEBUG
qDebug() << " -> updateBackground(): mode:" << bgMode << "style:" << bgBrush.style();
#endif
d->s << QString("\t{\"b\": { \"m\": \"%1\", \"b\": {\"c\": \"%2\", \"s\": \"%3\"}}},\r\n")
.arg(bgMode)
.arg(bgBrush.color().name())
.arg(bgBrush.style());
}
示例5: saveOdfGradientStyle
QString KoOdfGraphicStyles::saveOdfGradientStyle(KoGenStyles &mainStyles, const QBrush &brush)
{
KoGenStyle gradientStyle;
if (brush.style() == Qt::RadialGradientPattern) {
const QRadialGradient *gradient = static_cast<const QRadialGradient*>(brush.gradient());
gradientStyle = KoGenStyle(KoGenStyle::RadialGradientStyle /*no family name*/);
gradientStyle.addAttributePercent("svg:cx", gradient->center().x() * 100);
gradientStyle.addAttributePercent("svg:cy", gradient->center().y() * 100);
gradientStyle.addAttributePercent("svg:r", gradient->radius() * 100);
gradientStyle.addAttributePercent("svg:fx", gradient->focalPoint().x() * 100);
gradientStyle.addAttributePercent("svg:fy", gradient->focalPoint().y() * 100);
} else if (brush.style() == Qt::LinearGradientPattern) {
const QLinearGradient *gradient = static_cast<const QLinearGradient*>(brush.gradient());
gradientStyle = KoGenStyle(KoGenStyle::LinearGradientStyle /*no family name*/);
gradientStyle.addAttributePercent("svg:x1", gradient->start().x() * 100);
gradientStyle.addAttributePercent("svg:y1", gradient->start().y() * 100);
gradientStyle.addAttributePercent("svg:x2", gradient->finalStop().x() * 100);
gradientStyle.addAttributePercent("svg:y2", gradient->finalStop().y() * 100);
} else if (brush.style() == Qt::ConicalGradientPattern) {
const QConicalGradient * gradient = static_cast<const QConicalGradient*>(brush.gradient());
gradientStyle = KoGenStyle(KoGenStyle::ConicalGradientStyle /*no family name*/);
gradientStyle.addAttributePercent("svg:cx", gradient->center().x() * 100);
gradientStyle.addAttributePercent("svg:cy", gradient->center().y() * 100);
gradientStyle.addAttribute("draw:angle", QString("%1").arg(gradient->angle()));
}
const QGradient * gradient = brush.gradient();
if (gradient->spread() == QGradient::RepeatSpread)
gradientStyle.addAttribute("svg:spreadMethod", "repeat");
else if (gradient->spread() == QGradient::ReflectSpread)
gradientStyle.addAttribute("svg:spreadMethod", "reflect");
else
gradientStyle.addAttribute("svg:spreadMethod", "pad");
if (! brush.transform().isIdentity()) {
gradientStyle.addAttribute("svg:gradientTransform", saveTransformation(brush.transform()));
}
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
KoXmlWriter elementWriter(&buffer); // TODO pass indentation level
// save stops
QGradientStops stops = gradient->stops();
Q_FOREACH (const QGradientStop & stop, stops) {
elementWriter.startElement("svg:stop");
elementWriter.addAttribute("svg:offset", QString("%1").arg(stop.first));
elementWriter.addAttribute("svg:stop-color", stop.second.name());
if (stop.second.alphaF() < 1.0)
elementWriter.addAttribute("svg:stop-opacity", QString("%1").arg(stop.second.alphaF()));
elementWriter.endElement();
}
示例6: 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;
}
示例7: 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;
}
}
示例8: fillBackground
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF())//copy from QPlainTextEditor from 4.8.1
{
p->save();
if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) {
if (!gradientRect.isNull()) {
QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top());
m.scale(gradientRect.width(), gradientRect.height());
brush.setTransform(m);
const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode);
}
} else {
p->setBrushOrigin(rect.topLeft());
}
p->fillRect(rect, brush);
p->restore();
}
示例9: paint
void EventItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
painter->save();
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
QVariant value = index.data();
QBrush bgBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
QBrush fgBrush = qvariant_cast<QBrush>(index.data(Qt::ForegroundRole));
painter->setClipRect( opt.rect );
painter->setBackgroundMode(Qt::OpaqueMode);
painter->setBackground(Qt::transparent);
painter->setBrush(bgBrush);
if (bgBrush.style() != Qt::NoBrush) {
QPen bgPen;
bgPen.setColor(bgBrush.color().darker(250));
bgPen.setStyle(Qt::SolidLine);
bgPen.setWidth(1);
painter->setPen(bgPen);
painter->drawRoundedRect(opt.rect.x(), opt.rect.y(), opt.rect.width() - bgPen.width(), opt.rect.height() - bgPen.width(), 3.0, 3.0);
}
QTextDocument doc;
doc.setDocumentMargin(3);
doc.setDefaultStyleSheet("* {color: " + fgBrush.color().name() + ";}");
doc.setHtml("<html><qt></head><meta name=\"qrichtext\" content=\"1\" />" + displayText(value, QLocale::system()) + "</qt></html>");
QAbstractTextDocumentLayout::PaintContext context;
doc.setPageSize( opt.rect.size());
painter->translate(opt.rect.x(), opt.rect.y());
doc.documentLayout()->draw(painter, context);
painter->restore();
}
示例10: 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());
}
}
示例11: 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;
}
示例12: 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();
}
}
}
示例13: SetBlend
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush,
const QPen &linePen, int alpha)
{
SetBlend(true);
DisableTextures();
glEnableClientState(GL_VERTEX_ARRAY);
if (fillBrush.style() != Qt::NoBrush)
{
SetColor(fillBrush.color().red(), fillBrush.color().green(),
fillBrush.color().blue(), fillBrush.color().alpha());
GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, area);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
if (linePen.style() != Qt::NoPen)
{
SetColor(linePen.color().red(), linePen.color().green(),
linePen.color().blue(), linePen.color().alpha());
glLineWidth(linePen.width());
GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, area);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_LINE_LOOP, 0, 4);
}
glDisableClientState(GL_VERTEX_ARRAY);
}
示例14: saveOdf
void KoTableRowStyle::saveOdf(KoGenStyle &style) const
{
QList<int> keys = d->stylesPrivate.keys();
foreach(int key, keys) {
if (key == QTextFormat::BackgroundBrush) {
QBrush backBrush = background();
if (backBrush.style() != Qt::NoBrush)
style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::TableRowType);
else
style.addProperty("fo:background-color", "transparent", KoGenStyle::TableRowType);
} else if (key == MinimumRowHeight) {
style.addPropertyPt("style:min-row-height", minimumRowHeight(), KoGenStyle::TableRowType);
} else if (key == RowHeight) {
style.addPropertyPt("style:row-height", rowHeight(), KoGenStyle::TableRowType);
} else if (key == UseOptimalHeight) {
style.addProperty("style:use-optimal-row-height", useOptimalHeight(), KoGenStyle::TableRowType);
} else if (key == BreakBefore) {
style.addProperty("fo:break-before", KoText::textBreakToString(breakBefore()), KoGenStyle::TableRowType);
} else if (key == BreakAfter) {
style.addProperty("fo:break-after", KoText::textBreakToString(breakAfter()), KoGenStyle::TableRowType);
} else if (key == KeepTogether) {
if (keepTogether())
style.addProperty("fo:keep-together", "always", KoGenStyle::TableRowType);
else
style.addProperty("fo:keep-together", "auto", KoGenStyle::TableRowType);
}
}
}
示例15: 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);
}