本文整理汇总了C++中QTextFrame::lastPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrame::lastPosition方法的具体用法?C++ QTextFrame::lastPosition怎么用?C++ QTextFrame::lastPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFrame
的用法示例。
在下文中一共展示了QTextFrame::lastPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
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;
}
示例3: 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);
}
示例4: 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);
}
示例5: newLetter
//! [2]
void MainWindow::newLetter()
{
textEdit->clear();
QTextCursor cursor(textEdit->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextFrame *topFrame = cursor.currentFrame();
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
topFrameFormat.setPadding(16);
topFrame->setFrameFormat(topFrameFormat);
QTextCharFormat textFormat;
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
QTextCharFormat italicFormat;
italicFormat.setFontItalic(true);
QTextTableFormat tableFormat;
tableFormat.setBorder(1);
tableFormat.setCellPadding(16);
tableFormat.setAlignment(Qt::AlignRight);
cursor.insertTable(1, 1, tableFormat);
cursor.insertText("The Firm", boldFormat);
cursor.insertBlock();
cursor.insertText("321 City Street", textFormat);
cursor.insertBlock();
cursor.insertText("Industry Park");
cursor.insertBlock();
cursor.insertText("Some Country");
cursor.setPosition(topFrame->lastPosition());
cursor.insertText(QDate::currentDate().toString("d MMMM yyyy"), textFormat);
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText("Dear ", textFormat);
cursor.insertText("NAME", italicFormat);
cursor.insertText(",", textFormat);
for (int i = 0; i < 3; ++i)
cursor.insertBlock();
cursor.insertText(tr("Yours sincerely,"), textFormat);
for (int i = 0; i < 3; ++i)
cursor.insertBlock();
cursor.insertText("The Boss", textFormat);
cursor.insertBlock();
cursor.insertText("ADDRESS", italicFormat);
}
示例6: newLetter
void MainWindow::newLetter(){
chatbox->clear();
QTextCursor cursor(chatbox->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextFrame *topFrame = cursor.currentFrame();
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
topFrameFormat.setPadding(16);
topFrame->setFrameFormat(topFrameFormat);
QTextCharFormat textFormat;
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
QTextCharFormat italicFormat;
italicFormat.setFontItalic(true);
/*QTextTableFormat tableFormat;
tableFormat.setBorder(1);
tableFormat.setCellPadding(16);
tableFormat.setAlignment(Qt::AlignRight);
cursor.insertTable(1, 1, tableFormat);
cursor.insertText("The Firm", boldFormat);
cursor.insertBlock();
cursor.insertText("321 City Street", textFormat);
cursor.insertBlock();
cursor.insertText("Industry Park");
cursor.insertBlock();
cursor.insertText("Some Country"); */
cursor.setPosition(topFrame->lastPosition());
cursor.insertText("Railguy: ", boldFormat);
cursor.insertText("lol nub", textFormat);
cursor.insertBlock();
cursor.insertText("Chaos: ", boldFormat);
cursor.insertText("nou", textFormat);
cursor.insertBlock();
QFont font = chattitle->font();
font.setBold(true);
chattitle->setFont(font);
chattitle->setText("#General");
}
示例7: 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();
}
示例8: writeTable
//.........这里部分代码省略.........
m_cursor = table->cellAt(0, 2).firstCursorPosition();
m_cursor.insertHtml("C<sub>i</sub> ");
m_cursor = table->cellAt(0, 3).firstCursorPosition();
m_cursor.insertText("B");
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(0, j+4).firstCursorPosition();
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(j+1));
/* m_cursor.insertHtml(QString("C<sub>%1</sub> =").arg(j+1));
if(m_params->variableType(j) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(j))); */
}
m_cursor = table->cellAt(0, m_params->width()+4).firstCursorPosition();
m_cursor.insertText(QChar(0x0398)); // theta
/*
matrix, columnCompareOp, columnB, columnTheta
*/
for(size_t i=0; i < m_params->height(); i++)
{
m_cursor = table->cellAt(i+1, 0).firstCursorPosition();
m_cursor.insertText(QString("%1").arg(i+1));
// basis
m_cursor = table->cellAt(i+1, 1).firstCursorPosition();
size_t basisColumn = m_params->columnBasis(i);
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(basisColumn+1));
// basis C
m_cursor = table->cellAt(i+1, 2).firstCursorPosition();
if(m_params->variableType(basisColumn) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(basisColumn)));
// B
m_cursor = table->cellAt(i+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->columnB(i)));
// matrix
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(i+1, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->matrixA(i, j)));
}
// theta
m_cursor = table->cellAt(i+1, m_params->width()+4).firstCursorPosition();
if(m_params->columnTheta(i) > 0)
m_cursor.insertText(formatDouble(m_params->columnTheta(i)));
else
m_cursor.insertText("-");
}
/*
m+1 row
*/
m_cursor = table->cellAt(m_params->height()+1, 0).firstCursorPosition();
m_cursor.insertText("m+1");
m_cursor = table->cellAt(m_params->height()+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->F()));
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(m_params->height()+1, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->rowD(j)));
}
/*
m+2 row (for artificial variables)
*/
if(m_params->artificialFlag())
{
table->appendRows(1);
m_cursor = table->cellAt(m_params->height()+2, 0).firstCursorPosition();
m_cursor.insertText("m+2");
m_cursor = table->cellAt(m_params->height()+2, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->WF()));
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(m_params->height()+2, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->rowWD(j)));
}
}
/*
end of table
*/
m_cursor.endEditBlock();
m_cursor.setPosition(topFrame->lastPosition());
return true;
}