Reputation: 253
Qt3.3 used to allow for multiple selections in the QTextEdit widget by calling the setSelection() function and specifying a different selection id (selNum) as the last argument in that function.
In Qt4, to create a selection, I do it by creating a QTextCursor object and call the setPosition() or movePosition() methods. I have no problems being able to create a single selection of text. I am, however, unable to find a way to create multiple selections. The methods in Qt4 do not have an argument which allows you to set a selection id, nor can i find any other function in the QTextCursor or QTextEdit which looks like it might allow me to do so.
Has this feature been completely removed from Qt4? or has is there a new and different way of doing it?
Thanks.
Ronny
Upvotes: 1
Views: 1314
Reputation: 253
The solution, i realise now is actually quite simple.
To graphically visualise all the various selections (separate QTextCursor objects), instead of calling the setTextCursor() method for the QTextEdit widget for each of the selections, i change the background color of each of those sections of text by calling the setCharFormat() method for each of those QTextCursor objects.
Upvotes: 1
Reputation: 273516
How about creating multiple cursors (QTextCursor
), each selection a different portion of the text. Would that work for you?
Upvotes: 0