Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Trigger method when number of lines of QTextBlock changed in QPlainTextEdit
QtWS25 Last Chance

Trigger method when number of lines of QTextBlock changed in QPlainTextEdit

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for python
2 Posts 2 Posters 228 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Regex
    wrote on last edited by
    #1

    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 method

    lineCount()
    

    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

    JonBJ 1 Reply Last reply
    0
    • R Regex

      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 method

      lineCount()
      

      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

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @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/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved