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


C++ QTextOption::setWrapMode方法代码示例

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


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

示例1: QFrame

StyledLabel::StyledLabel(QWidget *parent)
    : QFrame(parent),
    _wrapMode(QTextOption::NoWrap),
    _alignment(Qt::AlignVCenter|Qt::AlignLeft),
    _toolTipEnabled(true),
    _resizeMode(NoResize)
{
    setMouseTracking(true);

    QTextOption opt = _layout.textOption();
    opt.setWrapMode(_wrapMode);
    opt.setAlignment(_alignment);
    _layout.setTextOption(opt);
}
开发者ID:sandsmark,项目名称:quassel-proxy,代码行数:14,代码来源:styledlabel.cpp

示例2: initLayoutHelper

void ChatItem::initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode wrapMode, Qt::Alignment alignment) const {
  Q_ASSERT(layout);

  layout->setText(data(MessageModel::DisplayRole).toString());

  QTextOption option;
  option.setWrapMode(wrapMode);
  option.setAlignment(alignment);
  layout->setTextOption(option);

  QList<QTextLayout::FormatRange> formatRanges
         = QtUi::style()->toTextLayoutList(formatList(), layout->text().length(), data(ChatLineModel::MsgLabelRole).toUInt());
  layout->setAdditionalFormats(formatRanges);
}
开发者ID:Yofel,项目名称:quassel-log-export,代码行数:14,代码来源:chatitem.cpp

示例3: QWidget

ItemSync::ItemSync(const QString &label, const QString &icon, ItemWidget *childItem)
    : QWidget( childItem->widget()->parentWidget() )
    , ItemWidgetWrapper(childItem, this)
    , m_label( new QTextEdit(this) )
    , m_icon( new IconWidget(icon, this) )
{
    auto layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->setSizeConstraint(QLayout::SetMinimumSize);

    auto labelLayout = new QHBoxLayout;
    connect( layout, &QVBoxLayout::destroyed,
             labelLayout, &QHBoxLayout::deleteLater );
    labelLayout->setContentsMargins(0, 0, 0, 0);
    labelLayout->setSpacing(0);

    labelLayout->addWidget(m_icon);
    labelLayout->addWidget(m_label);
    labelLayout->addStretch();

    layout->addLayout(labelLayout);

    QWidget *w = childItem->widget();
    layout->addWidget(w);
    w->setObjectName("item_child");
    w->setParent(this);

    m_label->setObjectName("item_child");

    m_label->document()->setDefaultFont(font());

    QTextOption option = m_label->document()->defaultTextOption();
    option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    m_label->document()->setDefaultTextOption(option);

    m_label->setReadOnly(true);
    m_label->setUndoRedoEnabled(false);

    m_label->setFocusPolicy(Qt::NoFocus);
    m_label->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_label->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_label->setFrameStyle(QFrame::NoFrame);
    m_label->setContextMenuPolicy(Qt::NoContextMenu);

    m_label->viewport()->installEventFilter(this);

    m_label->setPlainText(label);
}
开发者ID:hluk,项目名称:CopyQ,代码行数:49,代码来源:itemsync.cpp

示例4: initUi

void PsiTipLabel::initUi()
{
    margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this);
    setFrameStyle(QFrame::NoFrame);

    doc = new QTextDocument(this);
    QTextOption opt = doc->defaultTextOption();
    opt.setWrapMode(QTextOption::WordWrap);
    doc->setDefaultTextOption(opt);
    doc->setUndoRedoEnabled(false);
    doc->setDefaultFont(font());

    ensurePolished();
    setText(theText_);
}
开发者ID:psi-im,项目名称:psi,代码行数:15,代码来源:psitiplabel.cpp

示例5: textSize

QSizeF QwtRichTextEngine::textSize( const QFont &font,
    int flags, const QString& text ) const
{
    QwtRichTextDocument doc( text, flags, font );

    QTextOption option = doc.defaultTextOption();
    if ( option.wrapMode() != QTextOption::NoWrap )
    {
        option.setWrapMode( QTextOption::NoWrap );
        doc.setDefaultTextOption( option );
        doc.adjustSize();
    }

    return doc.size();
}
开发者ID:dcardenasnl,项目名称:Test,代码行数:15,代码来源:qwt_text_engine.cpp

示例6: paintPlaceHolderForInvisbleItem

void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
{
    qreal stripesWidth = 12;

    QRegion innerRegion = QRegion(boundingRect().adjusted(stripesWidth, stripesWidth, -stripesWidth, -stripesWidth).toRect());
    QRegion outerRegion  = QRegion(boundingRect().toRect()) - innerRegion;

    painter->setClipRegion(outerRegion);
    painter->setClipping(true);
    painter->fillRect(boundingRect().adjusted(1, 1, -1, -1), Qt::BDiagPattern);
    painter->setClipping(false);

    QString displayText = qmlItemNode().id();

    if (displayText.isEmpty())
        displayText = qmlItemNode().simplifiedTypeName();

    QTextOption textOption;
    textOption.setAlignment(Qt::AlignCenter);
    textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    if (boundingRect().width() > 60) {
        painter->save();

        QFont font;
        font.setStyleHint(QFont::SansSerif);
        font.setBold(true);
        font.setPixelSize(14);
        painter->setFont(font);

        QFontMetrics fm(font);
        if (fm.width(displayText) > (boundingRect().width() - 22) && displayText.length() > 4) {

            displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect().width() - 22, Qt::TextShowMnemonic);
        }

        painter->setPen(QColor(255, 255, 255, 128));
        painter->setCompositionMode(QPainter::CompositionMode_Exclusion);

        painter->drawText(boundingRect().adjusted(-2, -2, 0,0), displayText, textOption);

        painter->setFont(font);
        painter->setPen(QColor(0, 0, 0, 255));
        painter->drawText(boundingRect(), displayText, textOption);

        painter->restore();
    }
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:48,代码来源:formeditoritem.cpp

示例7: staticText

QStaticText ApiTraceFrame::staticText() const
{
    if (!m_staticText.text().isEmpty())
        return m_staticText;

    QString richText =
        QString::fromLatin1("<span style=\"font-weight:bold\">Frame %1</span>").arg(number);

    m_staticText.setText(richText);
    QTextOption opt;
    opt.setWrapMode(QTextOption::NoWrap);
    m_staticText.setTextOption(opt);
    m_staticText.prepare();

    return m_staticText;
}
开发者ID:bgirard,项目名称:apitrace,代码行数:16,代码来源:apitracecall.cpp

示例8: viewItemTextSize

static QSize viewItemTextSize ( const QStyleOptionViewItemV4 *option )
{
	QStyle *style = option->widget ? option->widget->style() : QApplication::style();
	QTextOption textOption;
	textOption.setWrapMode ( QTextOption::WrapAtWordBoundaryOrAnywhere );
	QTextLayout textLayout;
	textLayout.setTextOption ( textOption );
	textLayout.setFont ( option->font );
	textLayout.setText ( option->text );
	const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, option, option->widget ) + 1;
	QRect bounds ( 0,0,100 - 2*textMargin,600 );
	qreal height = 0, widthUsed = 0;
	viewItemTextLayout ( textLayout, bounds.width(), height, widthUsed );
	const QSize size ( qCeil ( widthUsed ), qCeil ( height ) );
	return QSize ( size.width() + 2 * textMargin, size.height() );
}
开发者ID:ForkkTest,项目名称:MultiMC5,代码行数:16,代码来源:instancedelegate.cpp

示例9: regenerate

void Text::regenerate()
{
    if (!doc) {
        doc = DocumentCache::getInstance().pop();
        dirty = true;
    }

    if (dirty) {
        doc->setDefaultFont(defFont);

        if (elide) {
            QFontMetrics metrics = QFontMetrics(defFont);
            QString elidedText = metrics.elidedText(text, Qt::ElideRight, qRound(width));

            doc->setPlainText(elidedText);
        } else {
            doc->setDefaultStyleSheet(defStyleSheet);
            doc->setHtml(text);
        }

        // wrap mode
        QTextOption opt;
        opt.setWrapMode(elide ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
        doc->setDefaultTextOption(opt);

        // width
        doc->setTextWidth(width);
        doc->documentLayout()->update();

        // update ascent
        if (doc->firstBlock().layout()->lineCount() > 0)
            ascent = doc->firstBlock().layout()->lineAt(0).ascent();

        // let the scene know about our change in size
        if (size != idealSize())
            prepareGeometryChange();

        // get the new width and height
        size = idealSize();

        dirty = false;
    }

    // if we are not visible -> free mem
    if (!keepInMemory)
        freeResources();
}
开发者ID:iphydf,项目名称:qTox,代码行数:47,代码来源:text.cpp

示例10: init

void TextItem::init()
{
    setTextInteractionFlags(Qt::TextEditorInteraction);
    setFlag(ItemIsSelectable, true);
    setFlag(ItemIsFocusable, true);

    QTextOption options;
    options.setWrapMode(QTextOption::NoWrap);
    options.setAlignment(Qt::AlignCenter);
    document()->setDefaultTextOption(options);

    connect(document(), &QTextDocument::contentsChanged, this, &TextItem::checkText);

    QFont f = font();
    f.setPixelSize(13);
    setFont(f);
}
开发者ID:choenig,项目名称:qt-creator,代码行数:17,代码来源:textitem.cpp

示例11: addBox

void PrintOut::addBox(int percent, const QString &text, Style style, Qt::Alignment halign)
{
    QTextOption options;
    options.setAlignment(halign | Qt::AlignTop);
    options.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    QFont f = f10;
    if (style == Strong)
        f.setBold(true);
    else if (style == Emphasis)
        f.setItalic(true);
    int wd = hsize * percent / 100;
    QRect r(cp.rect.x() + cp.rect.width(), 0, wd, vsize);
    const int ht = static_cast<int>(p.boundingRect(r, text, options).height());

    Box b(r, text, f, options);
    cp.boxes.append(b);
    cp.rect.setSize(QSize(cp.rect.width() + wd, qMax(cp.rect.height(), ht)));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:18,代码来源:printout.cpp

示例12: render_sequence

            void render_sequence( QPainter * painter, const QStyleOptionViewItem& option, const QString& text ) const {
                painter->save();
                QStyleOptionViewItemV4 op = option;
                QTextDocument document;
                QTextOption to;
                to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
                document.setDefaultTextOption( to );
				QFont font;
				font.setFamily( "Consolas" );
				document.setDefaultFont( font );
				document.setTextWidth( op.rect.width() );
                document.setHtml( text );
                op.widget->style()->drawControl( QStyle::CE_ItemViewItem, &op, painter );
                painter->translate( op.rect.topLeft() );
                QRect clip( 0, 0, op.rect.width(), op.rect.height() );
                document.drawContents( painter, clip );
                painter->restore();
            }
开发者ID:hermixy,项目名称:qtplatz,代码行数:18,代码来源:proteintable.cpp

示例13: paintEvent

void FlightItem::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter(this);
    const int i = (m_landscape ? 1 : 0);
    painter.setPen(palette().color(QPalette::BrightText));
    painter.drawText(QRect(columns[i][0] - 2, 0, columns[i][1] - columns[i][0], height()), m_scheduleTime.time().toString("hhmm"));
    painter.drawText(QRect(columns[i][1] - 2, 0, columns[i][2] - columns[i][1], height()), m_flightID);
    if (m_direction == FlightTimes::Arrivals)
        painter.drawText(QRect(columns[i][2] - 2, 0, columns[i][3] - columns[i][2], height()), m_beltNumber);
    else
        painter.drawText(QRect(columns[i][2] - 2, 0, columns[i][3] - columns[i][2], height()), m_gate);
    QTextOption option;
    option.setWrapMode(QTextOption::NoWrap);
    const QString name = (m_routeAirportNames.isEmpty() ? m_airportName : m_routeAirportNames);
    int last = width() > columns[i][5] ? columns[i][5] : columns[i][4];
    painter.drawText(QRect(columns[i][3] - 2, 0,  last - columns[i][3], height()), fontMetrics().elidedText(name, Qt::ElideRight, last - columns[i][3]), option);
    painter.drawText(QRect(last - 2, 0, width() - last, height()), m_statusText, option);
}
开发者ID:msorvig,项目名称:OpenFly,代码行数:19,代码来源:flightitem.cpp

示例14: paintEvent

void HelpWidget::paintEvent(QPaintEvent* e)
{
    Q_UNUSED(e);
    
    QRectF r = rect().adjusted(1, 1, -1, -1);
    
    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing);
    p.setPen(QColor(187, 174, 105));
    p.setBrush(QColor(242, 238, 184));
    p.drawRoundedRect(r, 4, 4);
    
    p.setPen(QColor(104, 74, 64));
    p.setFont(mFont);
    QTextOption options;
    options.setWrapMode(QTextOption::WordWrap);
    options.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    p.drawText(rect().adjusted(5, 5, -5, -5), mText, options);
}
开发者ID:chrono35,项目名称:chronomodel,代码行数:19,代码来源:HelpWidget.cpp

示例15: initDocument

void SenderChatItem::initDocument(QTextDocument *doc)
{
    // Hide double sender names
    QModelIndex lastIndex = model()->index(row()-1, column());
    if (lastIndex.isValid()
            && data(MessageModel::TypeRole).toInt() == Message::Plain
            && model()->data(lastIndex, MessageModel::TypeRole).toInt() == Message::Plain
            && (data(MessageModel::FlagsRole).toInt() & Message::Self) == (model()->data(lastIndex, MessageModel::FlagsRole).toInt() & Message::Self)) {
        doc->setPlainText("");
    }
    else {
        doc->setPlainText(data(MessageModel::DisplayRole).toString());
    }

    doc->setTextWidth(width());

    QTextOption o;
    o.setWrapMode(QTextOption::NoWrap);
    doc->setDefaultTextOption(o);
}
开发者ID:arneboe,项目名称:ProjectTox-Qt-GUI,代码行数:20,代码来源:chatitem.cpp


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