本文整理汇总了C++中QTextFrame::firstPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrame::firstPosition方法的具体用法?C++ QTextFrame::firstPosition怎么用?C++ QTextFrame::firstPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFrame
的用法示例。
在下文中一共展示了QTextFrame::firstPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert_frame
void QTextDocumentPrivate::insert_frame(QTextFrame *f)
{
int start = f->firstPosition();
int end = f->lastPosition();
QTextFrame *parent = frameAt(start-1);
Q_ASSERT(parent == frameAt(end+1));
if (start != end) {
// iterator over the parent and move all children contained in my frame to myself
for (int i = 0; i < parent->d_func()->childFrames.size(); ++i) {
QTextFrame *c = parent->d_func()->childFrames.at(i);
if (start < c->firstPosition() && end > c->lastPosition()) {
parent->d_func()->childFrames.removeAt(i);
f->d_func()->childFrames.append(c);
c->d_func()->parentFrame = f;
}
}
}
// insert at the correct position
int i = 0;
for (; i < parent->d_func()->childFrames.size(); ++i) {
QTextFrame *c = parent->d_func()->childFrames.at(i);
if (c->firstPosition() > end)
break;
}
parent->d_func()->childFrames.insert(i, f);
f->d_func()->parentFrame = parent;
}
示例2: addTextDocument
void QQuickTextNode::addTextDocument(const QPointF &position, QTextDocument *textDocument,
const QColor &textColor,
QQuickText::TextStyle style, const QColor &styleColor,
const QColor &anchorColor,
const QColor &selectionColor, const QColor &selectedTextColor,
int selectionStart, int selectionEnd)
{
QQuickTextNodeEngine engine;
engine.setTextColor(textColor);
engine.setSelectedTextColor(selectedTextColor);
engine.setSelectionColor(selectionColor);
engine.setAnchorColor(anchorColor);
engine.setPosition(position);
QList<QTextFrame *> frames;
frames.append(textDocument->rootFrame());
while (!frames.isEmpty()) {
QTextFrame *textFrame = frames.takeFirst();
frames.append(textFrame->childFrames());
engine.addFrameDecorations(textDocument, textFrame);
if (textFrame->firstPosition() > textFrame->lastPosition()
&& textFrame->frameFormat().position() != QTextFrameFormat::InFlow) {
const int pos = textFrame->firstPosition() - 1;
ProtectedLayoutAccessor *a = static_cast<ProtectedLayoutAccessor *>(textDocument->documentLayout());
QTextCharFormat format = a->formatAccessor(pos);
QRectF rect = a->frameBoundingRect(textFrame);
QTextBlock block = textFrame->firstCursorPosition().block();
engine.setCurrentLine(block.layout()->lineForTextPosition(pos - block.position()));
engine.addTextObject(rect.topLeft(), format, QQuickTextNodeEngine::Unselected, textDocument,
pos, textFrame->frameFormat().position());
} else {
QTextFrame::iterator it = textFrame->begin();
while (!it.atEnd()) {
Q_ASSERT(!engine.currentLine().isValid());
QTextBlock block = it.currentBlock();
engine.addTextBlock(textDocument, block, position, textColor, anchorColor, selectionStart, selectionEnd);
++it;
}
}
}
engine.addToSceneGraph(this, style, styleColor);
}
示例3:
static QTextFrame *findChildFrame(QTextFrame *f, int pos)
{
// ##### use binary search
QList<QTextFrame *> children = f->childFrames();
for (int i = 0; i < children.size(); ++i) {
QTextFrame *c = children.at(i);
if (pos >= c->firstPosition() && pos <= c->lastPosition())
return c;
}
return 0;
}
示例4: selectFrame
void MainWindow::selectFrame()
{
QTextCursor cursor = editor->textCursor();
QTextFrame *frame = cursor.currentFrame();
cursor.beginEditBlock();
cursor.setPosition(frame->firstPosition());
cursor.setPosition(frame->lastPosition(), QTextCursor::KeepAnchor);
cursor.endEditBlock();
editor->setTextCursor(cursor);
}
示例5: changeObjectFormat
void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
{
beginEditBlock();
int objectIndex = obj->objectIndex();
int oldFormatIndex = formats.objectFormatIndex(objectIndex);
formats.setObjectFormatIndex(objectIndex, format);
QTextBlockGroup *b = qobject_cast<QTextBlockGroup *>(obj);
if (b) {
b->d_func()->markBlocksDirty();
}
QTextFrame *f = qobject_cast<QTextFrame *>(obj);
if (f)
documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition());
QTextUndoCommand c = { QTextUndoCommand::GroupFormatChange, true, QTextUndoCommand::MoveCursor, oldFormatIndex,
0, 0, { obj->d_func()->objectIndex }, 0 };
appendUndoItem(c);
endEditBlock();
}