[PyQt] [PYQT] Increse the regex in QtCore.QRegExp
Maziar Parsijani
maziar.parsijani at gmail.com
Sat Sep 15 08:31:03 BST 2018
Hi,
I use this code in Qtextedit to find "sth" but the problem is when I have
more data it is lack on speed.
"""
cursor = self.SearchResults.textCursor()
format = QtGui.QTextCharFormat()
format.setBackground(QtGui.QBrush(QtGui.QColor("red")))
pp = self.m
pattern1 = r'\b(?:{})\b'.format(pp)
regex = QtCore.QRegExp(pattern1)
pos = 0
index = regex.indexIn(self.SearchResults.toPlainText(), pos)
tedad = 0
while (index != -1):
cursor.beginEditBlock()
cursor.setPosition(index)
cursor.movePosition(QtGui.QTextCursor.NextWord,
QtGui.QTextCursor.KeepAnchor, 1)
cursor.endEditBlock()
cursor.mergeCharFormat(format)
pos = index + regex.matchedLength()
index = regex.indexIn(self.SearchResults.toPlainText(), pos)
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180915/bad4776e/attachment.html>
More information about the PyQt
mailing list