PDA

View Full Version : Inline edit of multiline text widget?



zaphod.b
12th January 2015, 13:22
Hi all,

I require a multiline text widget that allows to edit parts of it while keeping the rest of the text ineditable; a kind of enhanced QTextEdit. Think of Qt Creator's CppEditor in refactor/rename mode, without synchronizing multiple occurrences, but simultaneous markup of editable text fragments.

Maybe this sketch helps to clarify:


readonly readonly readonly [inline editable] readonly
readonly readonly readonly readonly readonly [another
inline editable] readonly readonly readonly readonly

As indicated, an editable fragment should possibly line wrap, though this feature may be dispensable.
Editable fragments should be highlighted and resize on edit as needed. The CppEditor way would be perfect.

I can't see how to accomplish this out-of-Qt's-box. Is it already provided somehow? Is there additional work available elsewhere that provides such a widget? Else, how would you approach this task if you'd implement it yourself?

Thank you for your ideas.

(I apologize for not digging into Qt Creator's source code beforehand... Looking for a shortcut. :rolleyes:)

zaphod.b
15th January 2015, 13:27
anyone...?

Ginsengelf
15th January 2015, 15:18
Hi, maybe you can play with the cursor positions: each time the cursor is moved to a non-editable area, move it to the end or start of the nearest editable section. Or you can try to mark the editable sections using the QTextDocument which is used by a QTextEdit.

Ginsengelf

zaphod.b
15th January 2015, 16:19
Thx for your input, Ginsengelf.

Sure, I'd have to manage a list of editable QTextFragments somehow. The somehow is my question; I'd rather not do this explicitly. As for the readonly, once I have that list, to filter edit events shouldn't be a big deal. The highlighting part troubles me most for now.

Downloaded the QtCreator sources and tried to extract what I need. However I am completely overwhelmed by the sheer size, just as I feared in the first place.

Still open for more... :)