简体   繁体   中英

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. 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.

Just for refrence, the initialisation of the QTextEdit:

self.text = QtGui.QTextEdit(self)

I believe you cannot use QScintilla directly with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM