QPlainTextEdit : Make block readonly?
Is it possible to make only few text blocks readonly and not whole qplaintextedit?
textblock is QTextCursor block.
Thank you :)
Can u elaborate a bit more on the requirement ….this could help to design a custom widget where in u can have QTextCursorblock (s) or some modification like MyQPlainTextEdit has a MyQTextContent and both of this can have their own implementations.
Need more details on requirement to put some concrete code fwd.
Consider a case when you editing some text in a editor. Now you open this(block of text) in new editor (with some more options) now I want unless I close that second editor first editor should make that selected text as readonly (not in selection mode anymore) that means I can edit any other text apart from that block (piece of text) in first editor.
Is it clear?
It is possible to do what you want. You should extend the QPlainTextEdit, and build in this sort of behavior. You can get the block(s) you are interested in and then customize how you want it to behave. These specific blocks can give you their bounds and then you can control events in these bounds. I think that should work. Not sure if there is an easier way.
Yes you can. E.g. for all non editable blocks use QTextBlock::setUserState() and give them 666. Then reimp keypress event or install an event filter and check if the cursor is in a block where the user value is 666. If so, don’t propagate the event. That’s all.
I’m looking for something like this. Cheers :)