SearchableTextEdit

class SearchableTextEdit : public QPlainTextEdit

A text editor that adds search functionality Use this instead of QPlainTextEdit in widgets that have a search bar.

Public Functions

explicit SearchableTextEdit(QWidget *parent = nullptr)
QPair<int, int> search(const QString &string, int options)

Search for a given string or regex in the document, selects the first match on or after the cursor.

Parameters:
  • string – String or regex to search

  • flags – Find flags

  • isRegex – True if regex, false otherwise

Returns:

<index, count> where index is currently selected index and count is total number of matches

int findNext()

returns new index

int findPrev()
int findLast()
void clearSearch()

Public Slots

void highlightMatches()