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


C++ QTextCursor::insertBlock方法代码示例

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


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

示例1: insertFromMimeData

void ScCodeEditor::insertFromMimeData ( const QMimeData * data )
{
    if (data->hasUrls()) {
        QTextCursor cursor = textCursor();
        QList<QUrl> urls = data->urls();
        bool multiple = urls.size() > 1;
        if (multiple) {
            cursor.insertText("[");
            cursor.insertBlock();
        }
        for (int i = 0; i < urls.size(); ++ i) {
            QUrl url = urls[i];
            cursor.insertText("\"");
            if ( QURL_IS_LOCAL_FILE(url) )
                cursor.insertText(url.toLocalFile());
            else
                cursor.insertText(url.toString());
            cursor.insertText("\"");
            if (i < urls.size() - 1) {
                cursor.insertText(",");
                cursor.insertBlock();
            }
        }
        if (multiple) {
            cursor.insertBlock();
            cursor.insertText("]");
        }
    }
    else
        QPlainTextEdit::insertFromMimeData(data);
}
开发者ID:vanhuman,项目名称:supercollider-rvh,代码行数:31,代码来源:sc_editor.cpp

示例2: moveLineUpDown

void GenericCodeEditor::moveLineUpDown(bool up)
{
    // directly taken from qtcreator
    // Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
    // GNU Lesser General Public License
    QTextCursor cursor = textCursor();
    QTextCursor move = cursor;

    move.setVisualNavigation(false); // this opens folded items instead of destroying them

    move.beginEditBlock();

    bool hasSelection = cursor.hasSelection();

    if (cursor.hasSelection()) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
        move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock,
                          QTextCursor::KeepAnchor);
    } else {
        move.movePosition(QTextCursor::StartOfBlock);
        move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    }
    QString text = move.selectedText();

    move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
    move.removeSelectedText();

    if (up) {
        move.movePosition(QTextCursor::PreviousBlock);
        move.insertBlock();
        move.movePosition(QTextCursor::Left);
    } else {
        move.movePosition(QTextCursor::EndOfBlock);
        if (move.atBlockStart()) { // empty block
            move.movePosition(QTextCursor::NextBlock);
            move.insertBlock();
            move.movePosition(QTextCursor::Left);
        } else {
            move.insertBlock();
        }
    }

    int start = move.position();
    move.clearSelection();
    move.insertText(text);
    int end = move.position();

    if (hasSelection) {
        move.setPosition(start);
        move.setPosition(end, QTextCursor::KeepAnchor);
    }

    move.endEditBlock();

    setTextCursor(move);
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:58,代码来源:editor.cpp

示例3: copyUpDown

void GenericCodeEditor::copyUpDown(bool up)
{
    // directly taken from qtcreator
    // Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
    // GNU Lesser General Public License
    QTextCursor cursor = textCursor();
    QTextCursor move = cursor;
    move.beginEditBlock();

    bool hasSelection = cursor.hasSelection();

    if (hasSelection) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
        move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock,
                          QTextCursor::KeepAnchor);
    } else {
        move.movePosition(QTextCursor::StartOfBlock);
        move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    }

    QString text = move.selectedText();

    if (up) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.insertBlock();
        move.movePosition(QTextCursor::Left);
    } else {
        move.movePosition(QTextCursor::EndOfBlock);
        if (move.atBlockStart()) {
            move.movePosition(QTextCursor::NextBlock);
            move.insertBlock();
            move.movePosition(QTextCursor::Left);
        } else {
            move.insertBlock();
        }
    }

    int start = move.position();
    move.clearSelection();
    move.insertText(text);
    int end = move.position();

    move.setPosition(start);
    move.setPosition(end, QTextCursor::KeepAnchor);

    move.endEditBlock();

    setTextCursor(move);
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:52,代码来源:editor.cpp

示例4: addParagraph

void MainWindow::addParagraph(const QString &paragraph){
    if (paragraph.isEmpty())
        return;
    QTextDocument *document = chatbox->document();
    QTextCursor cursor = document->find(tr("Yours sincerely,"));
    if (cursor.isNull())
        return;
    cursor.beginEditBlock();
    cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2);
    cursor.insertBlock();
    cursor.insertText(paragraph);
    cursor.insertBlock();
    cursor.endEditBlock();

}
开发者ID:ChaoticConundrum,项目名称:yaptlytoti,代码行数:15,代码来源:mainwindow.cpp

示例5: BuildContactsSection

// 3) CONTACTS
void ResWaReport::BuildContactsSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n3) Contacts (proactive outreach events\n", _headerFormat);
    cursor.insertText("!! This information is not available !!\n", _headerFormat);
}
开发者ID:jadmr,项目名称:cpts483_Summer2015_drc,代码行数:8,代码来源:reswareport.cpp

示例6: BuildTrainingSection

// 4) TRAINING
void ResWaReport::BuildTrainingSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n4) TRAINING & IN-SERVICES\n");

    // VALUES
    int numTrainings;
    int numAttendingTrainings;
    CalculateTraining(numTrainings, numAttendingTrainings);
//    cursor.insertText("\t\t\t# of trainings: " + QString::number(numTrainings) + "\n");
//    cursor.insertText("\t\t\t# attending trainings: " + QString::number(numAttendingTrainings) + "\n");

    QTextTableFormat tableFormat;
    tableFormat.setHeaderRowCount(1);
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 35);
    constraints << QTextLength(QTextLength::PercentageLength, 35);

    tableFormat.setColumnWidthConstraints(constraints);
    QTextTable *table = cursor.insertTable(2, 2, tableFormat);
    // HEADERS
    TextToCell(table, 0, 0, "# of trainings (observers)", &_tableTextFormat);
    TextToCell(table, 0, 1, "# attending trainings (all people in room)", &_tableTextFormat);
    // VALUES
    TextToCell(table, 1, 0, QString::number(numTrainings), &_tableCellBlue);
    TextToCell(table, 1, 1, QString::number(numAttendingTrainings), &_tableCellBlue);
}
开发者ID:jadmr,项目名称:cpts483_Summer2015_drc,代码行数:29,代码来源:reswareport.cpp

示例7: addProgressText

void ZModemDialog::addProgressText(const QString& text)
{
    QTextCursor cursor = _textEdit->textCursor();

    cursor.insertBlock();
    cursor.insertText(text);
}
开发者ID:ktuan89,项目名称:konsole-4.8.5,代码行数:7,代码来源:ZModemDialog.cpp

示例8: BuildHeaderSection

void MediationProcess::BuildHeaderSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();  //  Is this necessary?
    cursor.insertText("\nMediation\n", _headerFormat);
    cursor.insertText("Inquiry, Mediation and Session types and statuses\n", _tableTextFormat);
}
开发者ID:lansdon,项目名称:cpts483_drc,代码行数:7,代码来源:mediationprocess.cpp

示例9: slotPasteAsQuotation

void ComposerTextEdit::slotPasteAsQuotation()
{
    QString text = qApp->clipboard()->text();
    if (text.isEmpty())
        return;

    QStringList lines = text.split(QLatin1Char('\n'));
    for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it) {
        it->remove(QLatin1Char('\r'));
        if (it->startsWith(QLatin1Char('>'))) {
            *it = QLatin1Char('>') + *it;
        } else {
            *it = QLatin1String("> ") + *it;
        }
    }
    text = lines.join(QStringLiteral("\n"));
    if (!text.endsWith(QLatin1Char('\n'))) {
        text += QLatin1Char('\n');
    }

    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();
    cursor.insertBlock();
    cursor.insertText(text);
    cursor.endEditBlock();
    setTextCursor(cursor);
}
开发者ID:ChristopherCotnoir,项目名称:trojita,代码行数:27,代码来源:ComposerTextEdit.cpp

示例10: exp

	QTextList *tryReadList(QTextList *list, const QString &line)
	{
		QTextList *listOut = list;
		QRegularExpression exp("^( *)(\\d+\\.|\\*) (.*)$");
		QRegularExpressionMatch match = exp.match(line);
		if (match.hasMatch())
		{
			const int indent = match.captured(1).size() / 2 + 1;
			const QString contents = match.captured(3);
			const bool ordered = match.captured(2) != "*";
			QTextListFormat fmt;
			fmt.setStyle(ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
			fmt.setIndent(indent);
			if (!listOut || fmt != listOut->format())
			{
				listOut = cursor.insertList(fmt);
			}
			else
			{
				cursor.insertBlock();
			}
			readInlineText(contents);
			listOut->add(cursor.block());
			return listOut;
		}
		else
		{
			return 0;
		}
	}
开发者ID:02JanDal,项目名称:QMarkdown,代码行数:30,代码来源:QMarkdown.cpp

示例11: _insertPrompt

void TabTerminal::_insertPrompt()
{
	QTextCursor cursor = textCursor();
	cursor.insertBlock();
	insertHtml(_userPrompt);
	ensureCursorVisible();
}
开发者ID:puzzleSEQ,项目名称:client,代码行数:7,代码来源:tabTerminal.cpp

示例12: setTextFont

// 设置字体格式
void MainWindow::setTextFont(bool checked)
{
    // 如果处于选中状态
    if(checked){
        QTextCursor cursor = ui->textEdit->textCursor();

        // 文本块格式
        QTextBlockFormat blockFormat;
        // 水平居中
        blockFormat.setAlignment(Qt::AlignCenter);
        // 使用文本块格式
        cursor.insertBlock(blockFormat);

        // 字符格式
        QTextCharFormat charFormat;
        // 背景色
        charFormat.setBackground(Qt::lightGray);
        // 字体颜色
        charFormat.setForeground(Qt::blue);
        // 使用宋体,12号,加粗,倾斜
        charFormat.setFont(QFont(tr("宋体"),12,QFont::Bold,true));

        // 使用下划线
        charFormat.setFontUnderline(true);
        // 使用字符格式
        cursor.setCharFormat(charFormat);
        // 插入文本
        cursor.insertText(tr("测试字体"));
    }
    // 如果处于非选中状态,可以进行其他操作
    else{/*恢复默认的字体格式*/}
}
开发者ID:Rookiee,项目名称:Qt_Codes,代码行数:33,代码来源:mainwindow.cpp

示例13: appendMessageToCurrentSession

/*! Append a new message to the current session and scroll to the end of the message protocol and
    returns true if the action was successful. The \a messageColor defines the color of the message
    box and should be provided as a full-color (no dimming required) color, as it is automatically
    adjusted for the border and background.
*/
bool QwcPrivateMessager::appendMessageToCurrentSession(QTextDocument *document, const QString message, const QColor messageColor)
{
    if (!document) { return false; }

    QTextCursor cursor = document->rootFrame()->lastCursorPosition();
    cursor.movePosition(QTextCursor::StartOfBlock);

    QTextFrameFormat frameFormat;
    frameFormat.setPadding(4);
    frameFormat.setBackground(messageColor.lighter(190));
    frameFormat.setMargin(0);
    frameFormat.setBorder(2);
    frameFormat.setBorderBrush(messageColor.lighter(150));
    frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Outset);

    // Title
    QTextCharFormat backupCharFormat = cursor.charFormat();

    QTextCharFormat newCharFormat;
    newCharFormat.setFontPointSize(9);

    QTextBlockFormat headerFormat;
    headerFormat.setAlignment(Qt::AlignHCenter);
    cursor.insertBlock(headerFormat);
    cursor.setCharFormat(newCharFormat);
    cursor.insertText(QDateTime::currentDateTime().toString());

    QTextFrame *frame = cursor.insertFrame(frameFormat);
    cursor.setCharFormat(backupCharFormat);
    frame->firstCursorPosition().insertText(message);

    return true;
}
开发者ID:pcjpnet,项目名称:qwired-suite,代码行数:38,代码来源:QwcPrivateMessager.cpp

示例14: textCursor

//	Flush the message history by flushing all current events
void
WChatLog::ChatLog_EventsRemoveAll()
	{
	clear();
	QTextCursor oTextCursor = textCursor();
	oTextCursor.insertBlock();
	m_oTextBlockComposing = oTextCursor.block();
	}
开发者ID:voodoo-chile,项目名称:Cambrian-src,代码行数:9,代码来源:WChatLog.cpp

示例15: beginNewLine

QTextCursor IrcChatBuffer::beginNewLine()
{
    QTextCursor cur (this->document());
    cur.movePosition(QTextCursor::End);
    cur.insertBlock();

    return cur;
}
开发者ID:DrFrankenstein,项目名称:IrcClient,代码行数:8,代码来源:ircchatbuffer.cpp


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