Important: Please read the Qt Code of Conduct -

QTextDocument.find() does not accept QRegularExpression? Say it isn't so...?

  • It appears that in Qt5.3, the find() method of QTextDocument does not have a variant supporting QRegularExpression? It only accepts the old QRegExp?

    I am working on version 2 of a specialized editor based on QPlainTextEdit, and I had expected to provide full PCRE syntax in the Find feature, instead of the very limited regex syntax of QRegExp that I could offer before.

    Please tell me I have misunderstood and the support is actually there? If not, the workarounds are very awkward...

  • Lifetime Qt Champion


    No, you didn't misunderstood, however, it's a work in progress.

  • Thanks for the reply. You wouldn't care to speculate as to what dot-number it would appear? 5-something or later than 5.x?

    My current plan for getting good REs is to bring the document into the Python realm with myEditor.toPlainText() and operate on it with the excellent regex library ( This gets me great features but at the performance cost of copying the whole document from the Qt domain to the Python domain, and the complexity of then carrying the position and length of a matched string back as (position, anchor) in a cursor.

  • Lifetime Qt Champion

    If everything goes well, maybe 5.5 but not before, 5.4 has reached feature freeze.

  • That's better than I hoped. Perhaps I will go with the old code using QRegExp and hope to upgrade smoothly later...

Log in to reply