Reputation: 702
So, the method select(SelectionType)
in the class QTextCursor
only has 4 possible parameters.
QTextCursor::Document
QTextCursor::BlockUnderCursor
QTextCursor::LineUnderCursor
QTextCursor::WordUnderCursor
Is it possible to create custom selectiontypes? Say if I want to select the text from position 5 to 9. Thanks!
http://doc.qt.io/qt-5/qtextcursor.html#select
Upvotes: 0
Views: 1115
Reputation: 11513
Use setPosition
like this:
cursor.setPosition(5);
cursor.setPosition(9, QTextCursor::KeepAnchor);
This will set the cursor's Anchor to 5 and its Position to 9. The selection is the text between anchor and position.
Upvotes: 3