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 signal after text has changed in QPlainTextEdit

Trigger signal after text has changed in QPlainTextEdit

Scheduled Pinned Locked Moved Solved Qt for Python
qt for python
3 Posts 2 Posters 998 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'm trying to trigger a method after the text inside a QPlainTextEdit has been changed.

    I tried to connect the signal textChanged with my method.
    However it seems that my method is not called at the end, not once the content of the QPlainTextEdit is changed.

    Indeed, if I copy/paste a bunch of lines in the QPlainTextEdit and look at the block count inside my method:
    document().blockCount() -> it returns the number of blocks before the change.

    My method should be called after because it is doing some manipulation with the blocks.

    I didn't find any signal triggered after the text has been changed.
    Do you have any idea how I can achieve such a thing ?
    Or is it possible to override a method of QPlainTextEdit to make a new signal doing what I want ?

    Thanks

    JonBJ 1 Reply Last reply
    0
    • R Regex

      Hello, I'm trying to trigger a method after the text inside a QPlainTextEdit has been changed.

      I tried to connect the signal textChanged with my method.
      However it seems that my method is not called at the end, not once the content of the QPlainTextEdit is changed.

      Indeed, if I copy/paste a bunch of lines in the QPlainTextEdit and look at the block count inside my method:
      document().blockCount() -> it returns the number of blocks before the change.

      My method should be called after because it is doing some manipulation with the blocks.

      I didn't find any signal triggered after the text has been changed.
      Do you have any idea how I can achieve such a thing ?
      Or is it possible to override a method of QPlainTextEdit to make a new signal doing what I want ?

      Thanks

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

      @Regex
      Hello and welcome.

      Assuming what you say is indeed the case (I haven't tested) then I would assume QPlainTextEdit::textChanged is a UI-widget signal emitted as soon as the text is changed but before that is committed to the document. I would then presume you need to look at QTextDocument signals to be emitted as the backing document gets modified, e.g. try void QTextDocument::contentsChanged()?

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Regex
        wrote on last edited by
        #3

        Hello @JonB
        It works correctly with QTextDocument::contentsChanged()
        Thanks

        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