[SOLVED] String selected by mouse in QTextEdit
-
Hi
I need to know which text is selected in QTextEdit by user.
I mean the text selected by mouse . I.e. the text that can be copied into the clipboard.I would to have the selected string , its length and position in text.
I'm using the foolowing code :
@
QTextEdit textViewer_ ;
QTextDocument *doc = textViewer_ . document() ;
QTextCursor crs( doc ) ;//textViewer_ . cursorRect () ; int beginPos = crs . selectionStart() ; int endPos = crs . selectionEnd() ; int pos = crs . position() ;
@
The result of this code :
beginPos == 0
endPos == 0
pos == 0How I use it :
I select the chunk of text in the QTextEdit widget
then press the button which execute specified code.Could you please advise the proper way this task solving ?
Thanks.
[edit: please use @ code tags , thanks, Eddy]