QTextEdit and text interaction
Hello,
My app uses a QPlainTextEdit-derived widget to display some data. The user should be unable to interact with the data in any way.
Currently, in my widget's constructor, I have the following:
Code:
setReadOnly(true);
setTextInteractionFlags(Qt::NoTextInteraction);
This seems to restrict most interactions. However, if the widget has focus, it is still possible to use Ctrl+A to select all the data, then Ctrl+C to copy it to the clipboard.
Is this a bug, or normal behavior? (I use Qt 4.6 btw.)
More importantly, what is the best way to prevent this? The only thing I can think of is writing my own event filter, but that seems a bit overkill/brute-force for what I'm trying to accomplish.
Thanks in advance.
Re: QTextEdit and text interaction
You can use a label inside a scrollarea instead of QPlainTextEdit if it's an option for you.
Re: QTextEdit and text interaction
Thanks for your reply. Since I use some QPlainTextEdit's facilities such as QPlainTextEdit::setExtraSelections() to display some information, using a label is not an option for me.
I ended up writing a simple "key press eater" event filter to disable Ctrl+A and Ctrl+C.
I'm still curious as to whether allowing Ctrl+A and Ctrl+C even when setTextInteraction(Qt::NoTextInteraction) has been called is intentional or not.