Answer the question
In order to leave comments, you need to log in
PyQt5.QsyntaxHighlighter How to re-highlight row n+1 after highlighting n rows?
I am writing a code editor in which there are modal commands (modifiers that act until they are explicitly canceled). I know how many rows will be highlighted by the connected my_QsyntaxHighlighter . I need to re-highlight the lines next before the explicit change of the modal command.
Question: where should the rehiglightNext function be run from? Launched from the last highlightBlock (determined by the counter), but it does not paint over the text until return does not work. That is, the last textblock will be colored after the lines following it are colored, and they will also have the last block, which will be colored after another copy of rehiglightNextfrom which I will immediately leave. Everything that is needed is highlighted except for the last line of the changed text and the last line on rehighlight. Departure occurs at the stage of exit from the nested highlight to the highlight level above. This beauty also ruins the debugger.
How can you see that the highlight of the changed lines of text is completely completed and you can proceed to reghilight ? I don't see any signals...
Maybe you can not connect highlight at all and its function was used directly...?
Answer the question
In order to leave comments, you need to log in
In short, I did not find a universal and beautiful way, so I just stuffed rehighlightNextBlocks into the eventFilter.
def eventFilter(self, widget, event):
if (event.type() == QEvent.KeyPress and widget is self):
key = event.key()
if действие1:
делаю действие1 руками не надеясь на return QWidget.eventFilter(self, widget, event)
rehighlightNextBlocks()
return True
elif действие2:
делаю действие2
rehighlightNextBlocks()
return True
return QWidget.eventFilter(self, widget, event)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question