Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I highlight a string with the specified number of line in QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How can I highlight a string with the specified number of line in QTextEdit?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 427 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.
  • Poor EnglishP Offline
    Poor EnglishP Offline
    Poor English
    wrote on last edited by
    #1

    what am I going to do to highlight a line string in QTextEdit? For example,I have a function that handles QTextEdit,which receives an int type of argument that specifies that line string and highlights it。This form of highlighting can be between highlighting and other forms(see chart below),in short,just highlighting it!thank your for read,sorry for my poor English!!
    alt text

    I am sorry about my poor English!

    JonBJ 1 Reply Last reply
    0
    • Poor EnglishP Poor English

      @JonB
      what frustrates me is that I cannot use Google because I am Chinese,and our domestic search, for some reason, is doing a mess!I couldn't find the answer I wanted,so I came here to ask question。I am glad to meet your answer,Mr.Cat
      Now, let me try to simplify my question:what I want to highlight a line of string in an entire article? that is,is there a more convenient way to set QTextCursor to a certain line?

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

      @Poor-English
      As far as I know, QTextCursor is indeed the correct way to do it.

      There is also QSyntaxHighlighter Class. I don't know if it is overkill for your usage, but you should have a look?

      Poor EnglishP 1 Reply Last reply
      3
      • Poor EnglishP Poor English

        what am I going to do to highlight a line string in QTextEdit? For example,I have a function that handles QTextEdit,which receives an int type of argument that specifies that line string and highlights it。This form of highlighting can be between highlighting and other forms(see chart below),in short,just highlighting it!thank your for read,sorry for my poor English!!
        alt text

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

        @Poor-English
        Do a Google for qtextedit highlight line and you will come up with several examples. You have to be careful about what exactly you mean by "line". It may be easier if you are able/choose to use a QPlainTextEdit.

        Poor EnglishP 1 Reply Last reply
        1
        • JonBJ JonB

          @Poor-English
          Do a Google for qtextedit highlight line and you will come up with several examples. You have to be careful about what exactly you mean by "line". It may be easier if you are able/choose to use a QPlainTextEdit.

          Poor EnglishP Offline
          Poor EnglishP Offline
          Poor English
          wrote on last edited by
          #3

          @JonB
          what frustrates me is that I cannot use Google because I am Chinese,and our domestic search, for some reason, is doing a mess!I couldn't find the answer I wanted,so I came here to ask question。I am glad to meet your answer,Mr.Cat
          Now, let me try to simplify my question:what I want to highlight a line of string in an entire article? that is,is there a more convenient way to set QTextCursor to a certain line?

          I am sorry about my poor English!

          JonBJ 1 Reply Last reply
          0
          • Poor EnglishP Poor English

            @JonB
            what frustrates me is that I cannot use Google because I am Chinese,and our domestic search, for some reason, is doing a mess!I couldn't find the answer I wanted,so I came here to ask question。I am glad to meet your answer,Mr.Cat
            Now, let me try to simplify my question:what I want to highlight a line of string in an entire article? that is,is there a more convenient way to set QTextCursor to a certain line?

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

            @Poor-English
            As far as I know, QTextCursor is indeed the correct way to do it.

            There is also QSyntaxHighlighter Class. I don't know if it is overkill for your usage, but you should have a look?

            Poor EnglishP 1 Reply Last reply
            3
            • JonBJ JonB

              @Poor-English
              As far as I know, QTextCursor is indeed the correct way to do it.

              There is also QSyntaxHighlighter Class. I don't know if it is overkill for your usage, but you should have a look?

              Poor EnglishP Offline
              Poor EnglishP Offline
              Poor English
              wrote on last edited by
              #5

              @JonB
              Thank you for your answers,and thank you for your QSystaxHighlighter ideas,now I will try to use other methods to solve the problems I encountered.
              Compared to win32 or MGC,Qt is really a weapon!I wonder why she didn't become popular(at least it seems to me),I don't know if it is popular abroad。。。

              I am sorry about my poor English!

              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