Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved simplest way to highlight some part of text in QTextEdit

    Qt for Python
    2
    5
    481
    Loading More Posts
    • 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.
    • S
      saeid0034 last edited by

      Hello, sorry if this question answered before (or there is some example of it)
      I want to show some text in QTextEdit and I want to highlight some word in it
      for example I have this very simple function to show text in QtextEdit

      def show_text(self, str):
          self.ui.textEdit.setText(str)
      

      For example I want when str is <nm> is 0x23 and #str is hi (its just a example and dont have any meaning) only <nm> and #str Highlight to other color
      I Know I can use QSyntaxHighlighter but sadly I cant find any good example of it

      1 Reply Last reply Reply Quote 0
      • S
        saeid0034 last edited by

        I found a good example here (in question)

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          The example from the documentation is pretty complete. Do you have more specific questions about it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply Reply Quote 2
          • S
            saeid0034 @SGaist last edited by

            @SGaist thank you, but you dont have any example in python?

            1 Reply Last reply Reply Quote 0
            • S
              saeid0034 last edited by

              I found a good example here (in question)

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                I haven't found it already translated but it's not the most complicated C++ code. The translation to Python is pretty straightforward.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post