Thanks,
I solved it like this (Python code, sorry) :
oldpos = my_cursor.position()
# selects the word under the cursor
# where the selction starts
newpos = my_cursor.selectionStart()
# select from new_pos to old_pos (order is important)
my_cursor.
setPosition(newpos, QtGui.
QTextCursor.
MoveAnchor)my_cursor.
setPosition(oldpos, QtGui.
QTextCursor.
KeepAnchor)self.editor.setTextCursor(my_cursor)
SearchedText = my_cursor.selectedText()
oldpos = my_cursor.position()
# selects the word under the cursor
my_cursor.select(QtGui.QTextCursor.WordUnderCursor)
# where the selction starts
newpos = my_cursor.selectionStart()
# select from new_pos to old_pos (order is important)
my_cursor.setPosition(newpos, QtGui.QTextCursor.MoveAnchor)
my_cursor.setPosition(oldpos, QtGui.QTextCursor.KeepAnchor)
self.editor.setTextCursor(my_cursor)
SearchedText = my_cursor.selectedText()
To copy to clipboard, switch view to plain text mode
Bookmarks