Solved How can I highlight a string with the specified number of line in QTextEdit?
-
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!!
-
@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-English
Do a Google forqtextedit 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 aQPlainTextEdit
. -
@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? -
@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?
-
@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。。。