本文整理汇总了C++中QTextBrowser::setTextCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBrowser::setTextCursor方法的具体用法?C++ QTextBrowser::setTextCursor怎么用?C++ QTextBrowser::setTextCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser::setTextCursor方法的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;
}
示例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();
}
}