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


C++ QTextBrowser::textCursor方法代码示例

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


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

示例1: doFind

void FindDialog::doFind(bool forward)
{
    QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser());
    sb->clearMessage();

    if (ui.comboFind->currentText() != findExpr || lastBrowser != browser)
        onceFound = false;
    findExpr = ui.comboFind->currentText();

    QTextDocument::FindFlags flags = 0;

    if (ui.checkCase->isChecked())
        flags |= QTextDocument::FindCaseSensitively;

    if (ui.checkWords->isChecked())
        flags |= QTextDocument::FindWholeWords;

    QTextCursor c = browser->textCursor();
    if (!c.hasSelection()) {
        if (forward)
            c.movePosition(QTextCursor::Start);
        else
            c.movePosition(QTextCursor::End);

        browser->setTextCursor(c);
    }

    QTextDocument::FindFlags options;
    if (forward == false)
        flags |= QTextDocument::FindBackward;

    QTextCursor found = browser->document()->find(findExpr, c, flags);
    if (found.isNull()) {
        if (onceFound) {
            if (forward)
                statusMessage(tr("Search reached end of the document"));
            else
                statusMessage(tr("Search reached start of the document"));
        } else {
            statusMessage(tr( "Text not found" ));
        }
    } else {
        browser->setTextCursor(found);
    }
    onceFound |= !found.isNull();
    lastBrowser = browser;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:47,代码来源:finddialog.cpp

示例2: findHelper

void FindEditor::findHelper(FindOption *opt)
{
    bool bFocus = m_findEdit->hasFocus();
    LiteApi::IEditor *editor = m_liteApp->editorManager()->currentEditor();
    if (!editor) {
        return;
    }
    LiteApi::ITextEditor *textEditor = LiteApi::getTextEditor(editor);
    QTextCursor find;
    if (textEditor) {
        QPlainTextEdit *ed = LiteApi::getPlainTextEdit(editor);
        if (ed) {
            find = findEditor(ed->document(),ed->textCursor(),opt);
            if (!find.isNull()) {
                ed->setTextCursor(find);
            }
        }
    } else {
        QTextBrowser *ed = LiteApi::findExtensionObject<QTextBrowser*>(editor,"LiteApi.QTextBrowser");
        if (ed) {
            find = findEditor(ed->document(),ed->textCursor(),opt);
            if (!find.isNull()) {
                ed->setTextCursor(find);
            }
        }
    }
    if (find.isNull()) {
        m_status->setText(tr("Not find"));
    } else {
        m_status->setText(QString("Ln:%1 Col:%2").
                              arg(find.blockNumber()+1).
                              arg(find.columnNumber()+1));
    }
    if (bFocus) {
        m_findEdit->setFocus();
    } else if (textEditor) {
        textEditor->onActive();
    }
}
开发者ID:hfeeki,项目名称:liteide,代码行数:39,代码来源:findeditor.cpp


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