Wordundercursor in QPlainTextEdit
-
Hi!
When we double click on word in QPlainTextEdit then its gets selected. In QTCreator when we double click it selects whole variable not just word. I mean it includes underscore,dashes, multiple words in one double click.
How can we implement such feature. What can we do so that just normal wordundercursor selects whole variable and not just single word.
Thanks,
Yash -
You have to use QTextEdit::ExtraSelection().
The only example that I have at hand is written in Python, but it's quite simple:Method in Line 694:
http://code.google.com/p/ninja-ide/source/browse/ninja_ide/gui/qt/main_panel/editor/editor.py?repo=kunai -
I know this already. This is not what I mean. I want when you double click it should select variable not word. like
@int m_word_word = 0@
m_word_word is variable but when you double click on it, then one word only will be selected not whole variable. Try this in QPlainTextEdit you will understand what I mean. -
Yes, but you have to use QTextEdit::ExtraSelection() to tell QTextEdit which are the words that are going to be highlighted.
Check out the link I mentioned... that is an IDE, where in that method the functionality that you mentioned is applied.