将行设置为只读 [英] setting line to read-only

查看:125
本文介绍了将行设置为只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看 QsciScintilla API,我想知道如何在文本编辑器中将一行设置为只读.我知道它提供了setReadOnly函数.但这会将整个文本编辑器设置为只读.

Ive been looking though the QsciScintilla API, and I want to know how to set a line in a text editor to read -only. I know it provides a setReadOnly function. But this sets the whole text editor to read-only.

关于如何将行设置为只读的任何建议?

Any suggestions on how to set a line to read-only?

我正在使用PQT4 Python 3x

Im using PQT4 Python 3x

推荐答案

您不能真正做到这一点.底层Scintilla控件中有一个低级功能,可以防止插入符号移动到文本区域中-但是它不能防止删除包含只读"文本的较大区域部分.但是,即使这足以满足您的目的,此功能也只能应用于样式的文本范围,而不能应用于特定的行.

You can't really do this. There is a low-level feature in the underlying Scintilla control that can prevent the caret moving into an area of text - but it cannot prevent deletion of a broader area of text that contains a "read-only" part. But even if this was sufficient for your purposes, this feature can only be applied to ranges of styled text, not specific lines.

如果您只想将某些只读文本与特定行相关联,则可以使用注释.

If you just want to associate some read-only text with a specific line, you could use an annotation.

这篇关于将行设置为只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆