[QScintilla] Multiple textChanged signals when indenting a selection with multiple lines

Chris Pezley chris.pezley at quantumwise.com
Tue May 31 08:59:03 BST 2016


I took a look at the Scintilla source and I see what you mean. In case 
anyone finds this who needs a solution, I've gotten around this using 
timers:

    from PyQt4 import QtGui, QtCore, Qsci


    class Editor(Qsci.QsciScintilla):
         def __init__(self, parent=None):
             super(Editor, self).__init__(parent)
             self.textChanged.connect(self.onTextChanged)

             self.changed_timer = QtCore.QTimer()
             self.changed_timer.setSingleShot(True)
             self.changed_timer.timeout.connect(self.changedCallback)

         def onTextChanged(self):
             self.changed_timer.start(10)

         def changedCallback(self):
             print "CHANGED"


    def main():
         app = QtGui.QApplication([])

         widget = Editor()
         widget.show()

         app.exec_()


    if __name__ == '__main__':
         main()



On 05/30/2016 07:31 PM, Phil Thompson wrote:
> On 30 May 2016, at 3:32 pm, Chris Pezley <chris.pezley at quantumwise.com> wrote:
>> Hi,
>>
>> I've noticed the following issue(?) when using qscintilla: highlight multiple lines in the editor and press tab. The textChanged signal is emitted once for every line that is indented. Since pressing delete with multiple lines selected only emits one textChanged, I would assume that the multiple emits is an error.
>>
>> I've included a small example to quickly test this. Just write a couple of lines, highlight them, press tab and then see the console output.
> It's a "feature" of the underlying Scintilla code.
>
> Phil



More information about the QScintilla mailing list