[英]How do I apply QScintilla syntax highlighting to a QTextEdit in PyQt4?
I have a simple PyQt text editor, and would like to apply QScintilla formatting to it.我有一个简单的 PyQt 文本编辑器,并想对其应用 QScintilla 格式。 I need to use a QTextEdit for the text, as it provides other functionality that I am using (cursor position, raw text output, etc), and would like to apply QScintilla formatting.我需要对文本使用 QTextEdit,因为它提供了我正在使用的其他功能(光标位置、原始文本输出等),并且想要应用 QScintilla 格式。
Just for refrence, the initialisation of the QTextEdit:仅供参考,QTextEdit 的初始化:
self.text = QtGui.QTextEdit(self)
I believe you cannot use QScintilla
directly with QTextEdit
.我相信您不能直接将QScintilla
与QTextEdit
。
But have a look at this question: stackoverflow.com/questions/20951660/… and if you want to see the usage QTextEdit
(or QPlainTextEdit
) with QSyntaxHiglighter
, see for example this:http://wiki.python.org/moin/PyQt/Python%20syntax%20highlighting or this http://carsonfarmer.com/2009/07/syntax-highlighting-with-pyqt/ which uses very basic syntax highlighter for Python code.但是看看这个问题:stackoverflow.com/questions/20951660/...如果你想看看QTextEdit
(或QPlainTextEdit
)和QSyntaxHiglighter
的用法,请参见例如:http : QPlainTextEdit
PyQt/Python%20syntax%20highlighting或这个http://carsonfarmer.com/2009/07/syntax-highlighting-with-pyqt/它使用非常基本的 Python 代码语法高亮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.