本文整理汇总了C++中QTextDocumentPrivate::find方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextDocumentPrivate::find方法的具体用法?C++ QTextDocumentPrivate::find怎么用?C++ QTextDocumentPrivate::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextDocumentPrivate
的用法示例。
在下文中一共展示了QTextDocumentPrivate::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: anchorAt
/*!
\fn QString QAbstractTextDocumentLayout::anchorAt(const QPointF &position) const
Returns the reference of the anchor the given \a position, or an empty
string if no anchor exists at that point.
*/
QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const
{
int cursorPos = hitTest(pos, Qt::ExactHit);
if (cursorPos == -1)
return QString();
// compensate for preedit in the hit text block
QTextBlock block = document()->firstBlock();
while (block.isValid()) {
QRectF blockBr = blockBoundingRect(block);
if (blockBr.contains(pos)) {
QTextLayout *layout = block.layout();
int relativeCursorPos = cursorPos - block.position();
const int preeditLength = layout ? layout->preeditAreaText().length() : 0;
if (preeditLength > 0 && relativeCursorPos > layout->preeditAreaPosition())
cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength);
break;
}
block = block.next();
}
QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle();
QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
return fmt.anchorHref();
}
示例2: anchorAt
/*!
\fn QString QAbstractTextDocumentLayout::anchorAt(const QPointF &position) const
Returns the reference of the anchor the given \a position, or an empty
string if no anchor exists at that point.
*/
QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const
{
int cursorPos = hitTest(pos, Qt::ExactHit);
if (cursorPos == -1)
return QString();
QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle();
QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
return fmt.anchorHref();
}
示例3: format
/*!
\fn QTextCharFormat QAbstractTextDocumentLayout::format(int position)
Returns the character format that is applicable at the given \a position.
*/
QTextCharFormat QAbstractTextDocumentLayout::format(int pos)
{
QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle();
int idx = pieceTable->find(pos).value()->format;
return pieceTable->formatCollection()->charFormat(idx);
}
示例4: formatIndex
/*!
\internal
Returns the index of the format at position \a pos.
*/
int QAbstractTextDocumentLayout::formatIndex(int pos)
{
QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle();
return pieceTable->find(pos).value()->format;
}