本文整理汇总了C++中QTextEdit::selectAll方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::selectAll方法的具体用法?C++ QTextEdit::selectAll怎么用?C++ QTextEdit::selectAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::selectAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEditorData
void ItemWidget::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QTextEdit *textEdit = qobject_cast<QTextEdit *>(editor);
if (textEdit != NULL) {
const QString text = index.data(Qt::EditRole).toString();
textEdit->setPlainText(text);
textEdit->selectAll();
}
}
示例2: slotSpellCheck
void PluginSpellCheck::slotSpellCheck()
{
// qDebug() << "Plugin parent : " << parent()->objectName() << " (" << parent()->metaObject()->className() << ")";
// The parent is assumed to be a NotepadPart
// Can't use qobject_cast here, we would need NotepadPart to be in a shared library.
if (!parent()->inherits("NotepadPart")) {
KMessageBox::error(0, QStringLiteral("You just called the spell-check action on a wrong part (not NotepadPart)"));
} else {
NotepadPart *part = (NotepadPart *) parent();
QTextEdit *widget = qobject_cast<QTextEdit *>(part->widget());
Q_ASSERT(widget);
widget->selectAll();
}
}
示例3: editMenuActivated
void editMenuActivated(QAction *action)
{
QWidget* w = qApp->focusWidget();
QTextEdit* te = qobject_cast<QTextEdit*>(w);
QLineEdit* le = qobject_cast<QLineEdit*>(w);
if (action == selectAction) {
highlighting = this;
return;
}
highlighting = 0;
if (action == copyAction) {
if (te) {
if (te->hasEditFocus()) {
te->copy();
} else {
QTextCursor c = te->textCursor();
te->selectAll();
te->copy();
te->setTextCursor(c); // reset selection
}
} else if (le) {
if (le->hasEditFocus()) {
le->copy();
} else {
qApp->clipboard()->setText(le->text());
}
}
} else if (action == pasteAction) {
// assumes clipboard is not empty if 'Paste' is able to be
// activated, otherwise the line/textedit might be cleared
// without pasting anything back into it
if (te) {
if (!te->hasEditFocus())
te->clear();
te->paste();
if (!te->hasEditFocus()) {
te->moveCursor(QTextCursor::Start);
te->ensureCursorVisible();
}
} else if (le) {
if (!le->hasEditFocus())
le->clear();
le->paste();
if (!le->hasEditFocus())
le->home(false);
}
}
}
示例4: getMultiLineText
QString QtopiaInputDialog::getMultiLineText(QWidget *parent, const QString &title, const QString &label,
QtopiaApplication::InputMethodHint hint, const QString &hintParam,
const QString &text, bool *ok)
{
QTextEdit *te = new QTextEdit;
QtopiaApplication::setInputMethodHint(te, hint, hintParam);
te->setPlainText(text);
te->setFocus();
te->selectAll();
te->setMinimumHeight(100);
QtopiaInputDialog dlg(parent, title, label, te);
QString result;
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
if (accepted)
result = te->toPlainText();
return result;
}
示例5: highlightMatches
void highlightMatches(const QString &pattern)
{
QTextEdit *ed = qobject_cast<QTextEdit *>(m_widget);
if (!ed)
return;
// Clear previous highlights.
ed->selectAll();
QTextCursor cur = ed->textCursor();
QTextCharFormat fmt = cur.charFormat();
fmt.setBackground(Qt::transparent);
cur.setCharFormat(fmt);
// Highlight matches.
QTextDocument *doc = ed->document();
QRegExp re(pattern);
cur = doc->find(re);
int a = cur.position();
while ( !cur.isNull() ) {
if ( cur.hasSelection() ) {
fmt.setBackground(Qt::yellow);
cur.setCharFormat(fmt);
} else {
cur.movePosition(QTextCursor::NextCharacter);
}
cur = doc->find(re, cur);
int b = cur.position();
if (a == b) {
cur.movePosition(QTextCursor::NextCharacter);
cur = doc->find(re, cur);
b = cur.position();
if (a == b) break;
}
a = b;
}
}
示例6: textEditSelectAll
// すべて選択
void MainWindow::textEditSelectAll() {
QTextEdit* textEdit = getCurrentTextEdit();
if (textEdit == NULL) return;
textEdit->selectAll();
}