本文整理汇总了C++中QTextBlock::clearLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBlock::clearLayout方法的具体用法?C++ QTextBlock::clearLayout怎么用?C++ QTextBlock::clearLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextBlock
的用法示例。
在下文中一共展示了QTextBlock::clearLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: documentChanged
/*! \reimp
*/
void TextDocumentLayout::documentChanged(int from, int /*charsRemoved*/, int charsAdded)
{
QTextDocument *doc = document();
int newBlockCount = doc->blockCount();
QTextBlock changeStartBlock = doc->findBlock(from);
QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsAdded - 1));
if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) {
QTextBlock block = changeStartBlock;
if (block.isValid() && block.layout()->lineCount()) {
QRectF oldBr = blockBoundingRect(block);
layoutBlock(block);
QRectF newBr = blockBoundingRect(block);
if (newBr.height() == oldBr.height()) {
if (!d->blockUpdate)
emit updateBlock(block);
return;
}
}
} else {
QTextBlock block = changeStartBlock;
do {
block.clearLayout();
if (block == changeEndBlock)
break;
block = block.next();
} while(block.isValid());
}
if (newBlockCount != d->blockCount) {
int changeEnd = changeEndBlock.blockNumber();
int blockDiff = newBlockCount - d->blockCount;
int oldChangeEnd = changeEnd - blockDiff;
if (d->maximumWidthBlockNumber > oldChangeEnd)
d->maximumWidthBlockNumber += blockDiff;
d->blockCount = newBlockCount;
if (d->blockCount == 1)
d->maximumWidth = blockWidth(doc->firstBlock());
if (!d->blockDocumentSizeChanged)
emit documentSizeChanged(documentSize());
if (blockDiff == 1 && changeEnd == newBlockCount -1 ) {
if (!d->blockUpdate)
{
QTextBlock b = changeStartBlock;
for(;;) {
emit updateBlock(b);
if (b == changeEndBlock)
break;
b = b.next();
}
}
return;
}
}
if (!d->blockUpdate)
emit update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); // optimization potential
}