Reputation: 605
I am using QTextCursor.WordUnderCursor
but it isn't working how I want it to, for example if I had:
(text)
it will only give (
OR text
OR )
not (text)
which is what I want. It also doesn't work with commas, $, #, etc.
Is there any way I can get it to work with those characters?
Upvotes: 2
Views: 565
Reputation:
QTextCursor.WordUnderCursor
considers a "word" to be an unbroken set of characters of the same class. I did some searching, and couldn't find how to change this behaviour.
However, it should be easy enough to get the word under the cursor, then progressively widening the selection using QTextCursor.setPostition()
, checking if the new character is "acceptable" and then doing that for both sides (left and right).
Upvotes: 2