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


C++ QTextDocument::defaultTextOption方法代码示例

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


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

示例1: ensureTextLayouted

void QLabelPrivate::ensureTextLayouted() const
{
    if (!textLayoutDirty)
        return;
    ensureTextPopulated();
    if (control) {
        QTextDocument *doc = control->document();
        QTextOption opt = doc->defaultTextOption();

        opt.setAlignment(QFlag(this->align));

        if (this->align & Qt::TextWordWrap)
            opt.setWrapMode(QTextOption::WordWrap);
        else
            opt.setWrapMode(QTextOption::ManualWrap);

        doc->setDefaultTextOption(opt);

        QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
        fmt.setMargin(0);
        doc->rootFrame()->setFrameFormat(fmt);
        doc->setTextWidth(documentRect().width());
    }
    textLayoutDirty = false;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: setShowWhitespace

void GenericCodeEditor::setShowWhitespace(bool show)
{
    QTextDocument *doc = textDocument();
    QTextOption opt( doc->defaultTextOption() );
    if( show )
        opt.setFlags( opt.flags() | QTextOption::ShowTabsAndSpaces );
    else
        opt.setFlags( opt.flags() & ~QTextOption::ShowTabsAndSpaces );
    doc->setDefaultTextOption(opt);
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:10,代码来源:editor.cpp

示例3: drawStandBy_

void DanmakuMove::drawStandBy_(){

	if (startPaintDMIndex_ <= dmCreater_->totalDMCount_) {
		return;
	}

	if (!isNeedUpdateStandBy_)
		return;
	else
		isNeedUpdateStandBy_ = false;

	QFont font;
	font.setBold(true);
	font.setFamily(QString("Microsoft YaHei"));
	font.setPixelSize(25);

	QString styleStr = QString(
		"<p>"
		"<span style = \" font-size:%1px; color:#FF9DCB; \">%2< / span>"
		"</p>");
	QString standByStr = styleStr.arg(font.pixelSize()).arg(tr("Stand By"));

	QTextDocument td;
	td.setDefaultFont(font);
	td.setDocumentMargin(10);

	QTextOption op = td.defaultTextOption();
	op.setAlignment(Qt::AlignHCenter);
	td.setDefaultTextOption( op );
	td.setHtml(standByStr);
	td.setTextWidth(dmSideWidSize_.width());
	QSize s = td.size().toSize();

	if (standByPix_)
		delete standByPix_;
	standByPix_ = new QPixmap(QSize(dmSideWidSize_.width(), 60));
	standByPix_->fill(Qt::transparent);
	QPainter p(standByPix_);
	p.setPen(QPen(QColor(0x49545A)));
	p.setBrush(QBrush(QColor(0x49545A), Qt::SolidPattern));
	p.setFont(font);

	int border = 1;
	QRect r(0, 0, standByPix_->width(), standByPix_->height());
	p.setOpacity(0.6);
	p.drawRoundedRect(r.adjusted(border, border, -border, -border), 3, 3);

	td.drawContents(&p);

	dmSideWidBKPixCache_->fill(Qt::transparent);
	QPainter pSideDM(dmSideWidBKPixCache_);
	pSideDM.drawPixmap(QPoint(0, dmSideWidBKPixCache_->height()-standByPix_->height()+border), *standByPix_);
}
开发者ID:dourgulf,项目名称:biliobs,代码行数:53,代码来源:danmakumove.cpp

示例4: setFlag

GraphicsTextItem::GraphicsTextItem(){
    setFlag(QGraphicsItem::ItemIsMovable);
    setFlag(QGraphicsItem::ItemIsSelectable);
    setFlag(QGraphicsItem::ItemIsFocusable);
    setAcceptDrops(true);
    setAcceptHoverEvents(true);


    QTextDocument *tdocument =  document();
    tdocument->setModified(true);
    QTextOption option = tdocument->defaultTextOption();
    option.setAlignment(Qt::AlignHCenter);
    tdocument->setDefaultTextOption(option);
    //setTextWidth(tdocument->idealWidth());
    setTextWidth(400);

}
开发者ID:ginozh,项目名称:my_wmm,代码行数:17,代码来源:mainwindow.cpp

示例5: layoutBlock

void TextDocumentLayout::layoutBlock(const QTextBlock &block)
{
    QTextDocument *doc = document();
    qreal margin = doc->documentMargin();
    qreal blockMaximumWidth = 0;

    qreal height = 0;
    QTextLayout *tl = block.layout();
    QTextOption option = doc->defaultTextOption();
    tl->setTextOption(option);

    int extraMargin = 0;
    if (option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) {
        QFontMetrics fm(block.charFormat().font());
        extraMargin += fm.width(QChar(0x21B5));
    }
    tl->beginLayout();
    qreal availableWidth = d->width;
    if (availableWidth <= 0) {
        availableWidth = qreal(INT_MAX); // similar to text edit with pageSize.width == 0
    }
    availableWidth -= 2*margin + extraMargin;
    qreal indentMargin = 0;
    while (1) {
        QTextLine line = tl->createLine();
        if (!line.isValid())
            break;
        line.setLeadingIncluded(true);
        line.setLineWidth(availableWidth - indentMargin);
        line.setPosition(QPointF(margin + indentMargin, height));
        if(!height) //enter only in the first iteration
        {
            indentMargin = indentWidth(block);
        }
        height += line.height();
        blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin);
    }
    tl->endLayout();

    int previousLineCount = doc->lineCount();
    const_cast<QTextBlock&>(block).setLineCount(block.isVisible() ? tl->lineCount() : 0);
    int lineCount = doc->lineCount();

    bool emitDocumentSizeChanged = previousLineCount != lineCount;
    if (blockMaximumWidth > d->maximumWidth) {
        // new longest line
        d->maximumWidth = blockMaximumWidth;
        d->maximumWidthBlockNumber = block.blockNumber();
        emitDocumentSizeChanged = true;
    } else if (block.blockNumber() == d->maximumWidthBlockNumber && blockMaximumWidth < d->maximumWidth) {
        // longest line shrinking
        QTextBlock b = doc->firstBlock();
        d->maximumWidth = 0;
        QTextBlock maximumBlock;
        while (b.isValid()) {
            qreal blockMaximumWidth = blockWidth(b);
            if (blockMaximumWidth > d->maximumWidth) {
                d->maximumWidth = blockMaximumWidth;
                maximumBlock = b;
            }
            b = b.next();
        }
        if (maximumBlock.isValid()) {
            d->maximumWidthBlockNumber = maximumBlock.blockNumber();
            emitDocumentSizeChanged = true;
        }
    }
    if (emitDocumentSizeChanged)// && !d->blockDocumentSizeChanged)
        emit documentSizeChanged(documentSize());

    emit updateBlock(block);
}
开发者ID:Bramas,项目名称:texiteasy,代码行数:72,代码来源:textdocumentlayout.cpp


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