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 1.0k 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 16 Dec 2022, 09:36 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

    J 1 Reply Last reply 16 Dec 2022, 10:28
    0
    • R Regex
      16 Dec 2022, 09:36

      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

      J Online
      J Online
      JonB
      wrote on 16 Dec 2022, 10:28 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 16 Dec 2022, 11:46 last edited by
        #3

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

        1 Reply Last reply
        0

        3/3

        16 Dec 2022, 11:46

        • Login

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