views:

39

answers:

1

I'm extending a QPlainTextEdit.

When I double click on a word containing a pipe char ex : {"foo"|upper|reverse} the whole text is surrounded.

I'd like to exclude the pipe char "|" from the selection and don't know what to do Is there a way to change the behavior of QTextCursor::WordUnderCursor?

I'd like that char to act the same as a space or more generally as an unselectable char.

As stated in QT docs:

Selects the word under the cursor. If the cursor is not positioned within a string of selectable characters, no text is selected.

+2  A: 

Currently there is no official way to change the way a text edit finds the word boundaries. See http://bugreports.qt.nokia.com/browse/QTBUG-150.

You may use their private API to change the behaviour of QTextEngine::atWordSeparator. This way is not recommanded by Qt. The pipe is recognized as word separator in 4.6 but not in 4.5.1 or earlier. I would suggest to update your Qt version, if that is an option. Otherwise you may give your QTextEdit a new QTextLayout with a modified QTextEngine.

merula
Thanks for your answer.
SleepyCod
Upgrading to QT 4.6 did the trick.
SleepyCod