How can I synchronize QTextCursor and the display cursor in QTextEdit? For example, when I move the text cursor,how can I move the display cursor to the same position?
How can I synchronize QTextCursor and the display cursor in QTextEdit? For example, when I move the text cursor,how can I move the display cursor to the same position?
You have to apply the cursor movement by setting the cursor on the text edit:
QTextEdit::setTextCursor()
J-P Nurmi
The problem is, after I set the text cursor, although I can move around the text cursor, the blinking display cursor does not move. That's why I want to synchronize them.
Another situation is, when I change the position of the blinking display cursor by clicking the mouse, how can I move the text cursor to the same position?
Sounds like there might be something wrong with the technique of moving the cursor. Are you doing it like this:
?Qt Code:
textEdit->setCursor(cursor); // apply visible cursorTo copy to clipboard, switch view to plain text mode
J-P Nurmi
I have the same problem with "synching" of the Text Cursor
This does not work - do you mean instead
Qt Code:
textEdit->setTextCursor(cursor); // apply visible cursorTo copy to clipboard, switch view to plain text mode
Sure, that sets the cursor. BUT clicking anywhere on the screen then moves the current "invisible" cursor -while the inactive cursor is shown.
Yes indeed, that's what I meant. Sorry for the typo.
Sorry, I don't understand what you mean. Could you rephrase? What are "invisible" and "inactive" cursors?Sure, that sets the cursor. BUT clicking anywhere on the screen then moves the current "invisible" cursor -while the inactive cursor is shown.
Clicking on a QTextEdit will move the cursor at the clicked point. Do you want to avoid that? Then you will have to subclass and override mousePressEvent() or install an event filter to prevent the QTextEdit implementation from handling the mouse press event.
J-P Nurmi
Me bad! I tried to use some good words that would explain the problem - but I think I didn't do a good job
No, not at all - that's exactly what I want. However the problem is that the "cursor" where new input from keyboard is moved to where you click, but the visible cursor symbol doesn'tmove where you click. I.e. you end up with a visible cursor symbol in one place and when you type the text will be inserted at the invisible cursor...
Sorry, I don't want to hijack this thread (although they sound the same)- I've started another thread which explains exactly what the problem is.
http://www.qtcentre.org/forum/f-qt-p...post29477.html
Bookmarks