pythonqtpyqtpyqt5qscintilla

the folding margin is not showing in my qsciscintilla text editor


i've experienced a problem that my qscintilla folding margin is not showing well. when i enable code folding, the margin wont appear on the middle of the text editor. however, when i browse the code on the web, i found that the code placed on the web will work

how can i resolve this problem? im using windows 11 64bit with python 3.11 and pyqt 5

qscintilla 2.13

mre:

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.Qsci import *


if __name__ == '__main__':
    app = QApplication([])
    w = QsciScintilla()
    l = QsciLexerCPP()
    l.setDefaultFont(QFont("Consolas"))
    l.setFoldCompact(False)
    l.setFoldComments(True)
    l.setFoldAtElse(True)
    l.setFoldPreoprocessor(True)
    w.setFolding(w.BoxedTreeFoldStyle, 2)
    w.setLexer(l)
    w.setIndentationWidth(4)
    w.setAutoIndent(True)
    w.setTabWidth(4)
    w.setUtf8(True)
    w.setMargins(1)
    w.setMarginWidth(1, 50)
    w.show()
    app.exec()


Solution

  • Please remove this line:

        w.setMargins(1)
    

    This sets only 1 (one) margin for your editor.