Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77316

QTextEdit declares itself changed due to highlighting changes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.8
    • GUI: Text handling
    • None

    Description

      I am writing a code editor. I want to let the user turn syntax highlighting on and off in the preferences. Unfortunately, QTextEdit seems to send a textChanged message as a result of any of the following:

      • adding a QSyntaxHighlighter
      • removing a QSyntaxHighlighter
      • a QSyntaxHighlighter performing highlighting

      I don't see any way to distinguish these textChanged signals from signals that legitimately indicate that the actual text has changed. (Since my code is responsible for adding/removing a highlighter, I can set a flag for myself to ignore the change message that I know I will receive across those operations; but I see no way to do that for the third case, especially since rehighlight is a non-virtual method. It would be useful for that to be virtual, to allow more flexible subclassing.)

      It seems to me that syntax highlighting should never result in a textChanged signal; the text has not changed. For clients who want to know even when syntax highlighting has changed, I would suggest adding a new signal.

      The end result of this bug is that my document state dirties unnecessarily, and I don't see a way to prevent that from happening. Not the end of the world, but not ideal.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            bhaller Ben Haller
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes