PDA

View Full Version : "Protecting" pieces of text



fullmetalcoder
3rd June 2007, 14:25
I'm using QTextDocument and related classes quite a lot and I came accross a problem : I want some text to be temporarily hidden. My current solution is to put it into a custom QTextBlockUserData which is attached to the block. The next problem is to ensure that this block can't be deleted and that the remaining text (which indicates that some text has been hidden) won't be modified. Is there any way to create a read-only" structure (block, frame, whatever...) within a QTextDocument ???

Another trouble is that the use of a block data sometimes break the Undo/Redo system because I di not find any way to catch this actions and adapt my custom block datas accordingly...

wysota
3rd June 2007, 14:32
Do you need that to implement code "folding" within the editor? Maybe it's better to hide it in the editor and not in the document? I don't know if it's possible, but it'd certainly be better to do it this way.

fullmetalcoder
3rd June 2007, 14:52
Do you need that to implement code "folding" within the editor? Maybe it's better to hide it in the editor and not in the document? I don't know if it's possible, but it'd certainly be better to do it this way.
It would probably be better... if it were possible... You see, Qt leave very little room for "real" subclassing. And the Trolls are wise but they seem to have forgotten some features... i've searched for such a solution but I did not find any... The only way would be to reimplement text rendering but Qt 4 does not allow that... Unless you redo everything from scratch...:(

As for the undo/redo I've just checked the sources and QTextDocument does not make use of the Undo framework so I also get screwed here...:(