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


C++ QTextCharFormat::background方法代码示例

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


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

示例1: on_valueEdit_currentCharFormatChanged

void WordEditFrame::on_valueEdit_currentCharFormatChanged(const QTextCharFormat &format)
{
    ui->boldButton->setFlat(ui->valueEdit->fontWeight()==50);
    ui->italicButton->setFlat(!ui->valueEdit->fontItalic());
    ui->underlineButton->setFlat(!ui->valueEdit->fontUnderline());
    ui->strikeOutButton->setFlat(!format.fontStrikeOut());

    disconnect(ui->fontComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_fontComboBox_currentIndexChanged(QString)));
    disconnect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(on_fontSizeSpinBox_valueChanged(int)));

    ui->fontComboBox->setCurrentFont(format.font());
    ui->fontSizeSpinBox->setValue((int)format.fontPointSize());

    connect(ui->fontComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_fontComboBox_currentIndexChanged(QString)));
    connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(on_fontSizeSpinBox_valueChanged(int)));

    QPalette aPalette=ui->textColorArea->palette();
    aPalette.setColor(QPalette::Window, format.foreground().color());
    ui->textColorArea->setPalette(aPalette);

    aPalette=ui->backgroundColorArea->palette();

    if (format.background().style()==Qt::NoBrush)
    {
        aPalette.setColor(QPalette::Window, QColor(255, 255, 255));
    }
    else
    {
        aPalette.setColor(QPalette::Window, format.background().color());
    }

    ui->backgroundColorArea->setPalette(aPalette);
}
开发者ID:Gris87,项目名称:ProtocolCreator,代码行数:33,代码来源:wordeditframe.cpp

示例2: paint

void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
  Q_UNUSED(option);
  Q_UNUSED(widget);

  const QAbstractItemModel *model_ = model();
  QModelIndex myIdx = model_->index(row(), 0);
  Message::Type type = (Message::Type)myIdx.data(MessageModel::TypeRole).toInt();
  UiStyle::MessageLabel label = (UiStyle::MessageLabel)myIdx.data(ChatLineModel::MsgLabelRole).toInt();

  QTextCharFormat msgFmt = QtUi::style()->format(UiStyle::formatType(type), label);
  if(msgFmt.hasProperty(QTextFormat::BackgroundBrush)) {
    painter->fillRect(boundingRect(), msgFmt.background());
  }

  if(_selection & Selected) {
    QTextCharFormat selFmt = QtUi::style()->format(UiStyle::formatType(type), label | UiStyle::Selected);
    if(selFmt.hasProperty(QTextFormat::BackgroundBrush)) {
      qreal left = item((ChatLineModel::ColumnType)(_selection & ItemMask))->pos().x();
      QRectF selectRect(left, 0, width() - left, height());
      painter->fillRect(selectRect, selFmt.background());
    }
  }

  // draw chatitems
  // the items draw themselves at the correct position
  timestampItem()->paint(painter, option, widget);
  senderItem()->paint(painter, option, widget);
  contentsItem()->paint(painter, option, widget);
}
开发者ID:bawNg,项目名称:quassel,代码行数:29,代码来源:chatline.cpp

示例3: applySettings

void GenericCodeEditor::applySettings( Settings::Manager *settings )
{
    settings->beginGroup("IDE/editor");

    bool lineWrap = settings->value("lineWrap").toBool();
    bool showWhitespace = settings->value("showWhitespace").toBool();
    mInactiveFadeAlpha = settings->value("inactiveEditorFadeAlpha").toInt();

    QPalette palette;

    settings->beginGroup("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);
    }

    if (settings->contains("lineNumbers")) {
        // NOTE: the line number widget will inherit the palette from the editor
        QTextCharFormat format = settings->value("lineNumbers").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Mid, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::ButtonText, fg);
    }

    if (settings->contains("selection")) {
        QTextCharFormat format = settings->value("selection").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Highlight, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::HighlightedText, fg);
    }

    mCurrentLineTextFormat = settings->value("currentLine").value<QTextCharFormat>();
    mSearchResultTextFormat = settings->value("searchResult").value<QTextCharFormat>();

    settings->endGroup(); // colors

    mHighlightCurrentLine = settings->value("highlightCurrentLine").toBool();
    updateCurrentLineHighlighting();

    settings->endGroup(); // IDE/editor

    setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap );
    setShowWhitespace( showWhitespace );
    setPalette(palette);
    
    setActiveAppearance(hasFocus());
}
开发者ID:mblewett,项目名称:supercollider,代码行数:59,代码来源:editor.cpp

示例4: applySettings

void GenericCodeEditor::applySettings( Settings::Manager *settings )
{
    settings->beginGroup("IDE/editor");

    bool lineWrap = settings->value("lineWrap").toBool();

    QPalette palette;

    settings->beginGroup("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);
    }

    if (settings->contains("lineNumbers")) {
        // NOTE: the line number widget will inherit the palette from the editor
        QTextCharFormat format = settings->value("lineNumbers").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Button, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::ButtonText, fg);
    }

    if (settings->contains("selection")) {
        QTextCharFormat format = settings->value("selection").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Highlight, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::HighlightedText, fg);
    }

    mSearchResultTextFormat = settings->value("searchResult").value<QTextCharFormat>();

    settings->endGroup(); // colors

    settings->endGroup(); // IDE/editor

    setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap );
    setPalette(palette);
}
开发者ID:Sybn,项目名称:supercollider,代码行数:50,代码来源:editor.cpp

示例5: backgroundBrush

QVariant ChatLineModelItem::backgroundBrush(UiStyle::FormatType subelement, bool selected) const
{
    QTextCharFormat fmt = QtUi::style()->format(UiStyle::formatType(_styledMsg.type()) | subelement, messageLabel() | (selected ? UiStyle::Selected : 0));
    if (fmt.hasProperty(QTextFormat::BackgroundBrush))
        return QVariant::fromValue<QBrush>(fmt.background());
    return QVariant();
}
开发者ID:GDXN,项目名称:quassel,代码行数:7,代码来源:chatlinemodelitem.cpp

示例6: 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);
}
开发者ID:mblewett,项目名称:supercollider,代码行数:32,代码来源:post_window.cpp

示例7: invertedColorFormat

static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
{
    QTextCharFormat rc = in;
    rc.setForeground(in.background());
    rc.setBackground(in.foreground());
    return rc;
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:7,代码来源:diffhighlighter.cpp

示例8: 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 );
}
开发者ID:tintinnabuli,项目名称:supercollider,代码行数:26,代码来源:post_window.cpp

示例9: currentCharFormatChanged

void TextEdit::currentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
    fontChanged(format.font());
    colorChanged(format.background().color());
}
开发者ID:Giova84,项目名称:LittleWriter,代码行数:7,代码来源:textedit.cpp

示例10: updateTextFormatDisplay

void EditorPage::updateTextFormatDisplay( QTreeWidgetItem *item )
{
    QTextCharFormat format = item->data( 0, DefaultTextFormatRole ).value<QTextCharFormat>();
    format.merge( item->data( 0, TextFormatRole ).value<QTextCharFormat>() );

    QBrush fg = format.foreground();
    if ( fg != Qt::NoBrush)
        item->setForeground( 0, fg );
    else
        item->setData( 0, Qt::ForegroundRole, QVariant() );

    QBrush bg = format.background();
    if ( bg != Qt::NoBrush)
        item->setBackground( 0, bg );
    else
        item->setData( 0, Qt::BackgroundRole, QVariant() );

    QFont f;
    if (format.hasProperty(QTextFormat::FontItalic))
        f.setItalic( format.fontItalic() );
    if (format.hasProperty(QTextFormat::FontWeight))
        f.setWeight( format.fontWeight() );

    item->setFont( 0, f );
}
开发者ID:SpaceAppsXploration,项目名称:supercollider,代码行数:25,代码来源:editor_page.cpp

示例11: addMixinStyle

void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
                                 const MixinTextStyles &mixinStyles) const
{
    for (TextStyle mixinStyle : mixinStyles) {
        const Format &format = m_scheme.formatFor(mixinStyle);

        if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) {
            if (format.foreground().isValid())
                textCharFormat.setForeground(format.foreground());
            else
                textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
                                                      format.relativeForegroundSaturation(),
                                                      format.relativeForegroundLightness()));
        }
        if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) {
            if (format.background().isValid())
                textCharFormat.setBackground(format.background());
            else
                textCharFormat.setBackground(mixBrush(textCharFormat.background(),
                                                      format.relativeBackgroundSaturation(),
                                                      format.relativeBackgroundLightness()));
        }
        if (!textCharFormat.fontItalic())
            textCharFormat.setFontItalic(format.italic());

        if (textCharFormat.fontWeight() == QFont::Normal)
            textCharFormat.setFontWeight(format.bold() ? QFont::Bold : QFont::Normal);

        if (textCharFormat.underlineStyle() == QTextCharFormat::NoUnderline) {
            textCharFormat.setUnderlineStyle(format.underlineStyle());
            textCharFormat.setUnderlineColor(format.underlineColor());
        }
    };
}
开发者ID:choenig,项目名称:qt-creator,代码行数:34,代码来源:fontsettings.cpp

示例12:

Format::Format (QTextCharFormat tcf, QObject* parent):QObject (parent)
{
	setBackground( tcf.background().color() );
	setForeground( tcf.foreground().color() );
	setBold( tcf.fontWeight() >= QFont::Bold );
	setItalic( tcf.fontItalic() );
	setPoints ( tcf.fontPointSize() );
}
开发者ID:tazio,项目名称:QtTail,代码行数:8,代码来源:format.cpp

示例13: QDialog

ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfigurationDialog),
    m_settings(0)
{
    ui->setupUi(this);

    // Filter out characters which are not allowed in a file name
    QRegExpValidator *fileNameValidator = new QRegExpValidator(ui->name);
    fileNameValidator->setRegExp(QRegExp(QLatin1String("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$")));
    ui->name->setValidator(fileNameValidator);

    updateDocumentation();
    connect(ui->name, SIGNAL(textChanged(QString)), this, SLOT(updateOkButton()));
    updateOkButton(); // force initial test.
    connect(ui->editor, SIGNAL(documentationChanged(QString,QString)),
            this, SLOT(updateDocumentation(QString,QString)));

    // Set palette and font according to settings
    const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::instance()->fontSettings();
    const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT);
    const QTextCharFormat selectionFormat = fs.toTextCharFormat(TextEditor::C_SELECTION);

    QPalette pal;
    pal.setColor(QPalette::Base, tf.background().color());
    pal.setColor(QPalette::Text, tf.foreground().color());
    pal.setColor(QPalette::Foreground, tf.foreground().color());
    if (selectionFormat.background().style() != Qt::NoBrush)
        pal.setColor(QPalette::Highlight, selectionFormat.background().color());
    pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
    ui->documentation->setPalette(pal);
    ui->editor->setPalette(pal);

    ui->documentation->setFont(tf.font());
    ui->editor->setFont(tf.font());

    // Set style sheet for documentation browser
    const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD);
    const QTextCharFormat tfParam = fs.toTextCharFormat(TextEditor::C_STRING);

    const QString css =  QString::fromLatin1("span.param {color: %1; background-color: %2;} "
                                             "span.option {color: %3; background-color: %4;} "
                                             "p { text-align: justify; } ")
            .arg(tfParam.foreground().color().name())
            .arg(tfParam.background().style() == Qt::NoBrush
                 ? QString() : tfParam.background().color().name())
            .arg(tfOption.foreground().color().name())
            .arg(tfOption.background().style() == Qt::NoBrush
                 ? QString() : tfOption.background().color().name())
            ;
    ui->documentation->document()->setDefaultStyleSheet(css);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:52,代码来源:configurationdialog.cpp

示例14: setBackground

void ItemEditorWidget::setBackground()
{
    QTextCursor tc = textCursor();
    QTextCharFormat format = tc.charFormat();

    QColorDialog dialog(this);
    dialog.setOptions(dialog.options() | QColorDialog::ShowAlphaChannel);
    dialog.setCurrentColor( format.background().color() );

    if ( dialog.exec() == QDialog::Accepted ) {
        const QColor color = dialog.selectedColor();
        format.setBackground(color);
        tc.setCharFormat(format);
    }
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:15,代码来源:itemeditorwidget.cpp

示例15: updateTextFormatDisplayCommons

void EditorPage::updateTextFormatDisplayCommons()
{
    QTextCharFormat commonFormat =
            mCommonTextFormatItem->data(0, TextFormatRole).value<QTextCharFormat>();

    QPalette palette;

    QBrush fg = commonFormat.foreground();
    if ( fg != Qt::NoBrush)
        palette.setBrush( QPalette::Text, fg );

    QBrush bg = commonFormat.background();
    if (bg != Qt::NoBrush)
        palette.setBrush( QPalette::Base, bg );

    ui->textFormats->setPalette(palette);
}
开发者ID:SpaceAppsXploration,项目名称:supercollider,代码行数:17,代码来源:editor_page.cpp


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