Ask Your Question
1

What is the appropriate method to choose text using QTextCursor without affecting performance?

asked 2022-09-06 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-08-10 10:00:00 +0000

devzero gravatar image

The appropriate method to choose text using QTextCursor without affecting performance is to use the QTextCursor::movePosition() method with the MoveMode parameter set to KeepAnchor. This method moves the cursor to the desired position while keeping the current selection (if any) intact, rather than clearing the selection and creating a new one. Additionally, you can also limit the amount of text being selected by specifying the number of characters to select using QTextCursor::setPosition() or QTextCursor::setPosition(), and then calling the movePosition() method. This way, you can select only the required text, minimizing the impact on performance.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-09-06 11:00:00 +0000

Seen: 8 times

Last updated: Aug 10 '22