Trigger method when number of lines of QTextBlock changed in QPlainTextEdit
-
Hello,
I have a QPlainTextEdit widget configured with
setLineWrapMode(QPlainTextEdit.WidgetWidth) # allows QTextBlock inside the QPlainTextEdit to be splitted into multiple lines
which is composed of multiple QTextBlock
Then based on the length of the block and the widget size, the block will be splitted into multiple lines.
I can recover the number of lines inside a block with methodlineCount()
Question:
Is it possible to get a signal or build a signal allowing to trigger a method each time the number of lines inside a block of the QPlainTextEdit widget change ?My goal:
On the left of my QPlainTextEdit, I have line numbers and I would like to adapt their size (height) so that the line number corresponding to a block match the size of the block (= line height * number of lines inside the block).
To achieve that, I need to trigger this computation each time the height of the block change (when its number of lines change)Thanks
-
Hello,
I have a QPlainTextEdit widget configured with
setLineWrapMode(QPlainTextEdit.WidgetWidth) # allows QTextBlock inside the QPlainTextEdit to be splitted into multiple lines
which is composed of multiple QTextBlock
Then based on the length of the block and the widget size, the block will be splitted into multiple lines.
I can recover the number of lines inside a block with methodlineCount()
Question:
Is it possible to get a signal or build a signal allowing to trigger a method each time the number of lines inside a block of the QPlainTextEdit widget change ?My goal:
On the left of my QPlainTextEdit, I have line numbers and I would like to adapt their size (height) so that the line number corresponding to a block match the size of the block (= line height * number of lines inside the block).
To achieve that, I need to trigger this computation each time the height of the block change (when its number of lines change)Thanks
@Regex
While you wait for a better answer.I don't think you will get a signal from Qt for the increased number of visible lines. You will get one for any change, and I would guess you then have to do the work to calculate if that has changed the number of lines.
Meanwhile you might Google for
qplaintextedit line numbers
. There are a few links which you might want to read through, e.g. https://stackoverflow.com/questions/2443358/how-to-add-lines-numbers-to-qtextedit or https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/