The code below creates a single QTextBrowser
, fills it with 25 lines of text and finds a line 'Line of text # 0011' using view.find
method which aside from finding the text selects it as well.
How to deselect the text selected by .find
method?
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
view = QtGui.QTextBrowser()
for i in range(25):
view.append('Line of text # %004d'%i )
view.moveCursor(QtGui.QTextCursor.End)
view.find('Line of text # 0011', QtGui.QTextDocument.FindBackward)
view.show()
app.exec_()