PDA

View Full Version : How to use QStringMatcher ?



unix7777
17th October 2009, 14:36
Hi everybody,

my question is mostly general not especially for QStringMatcher.

I wan to create widjet with Lineedit, Text edit and Qpushbutton.
When the user enter some text in the texteidt and than enter some word(string) in line edit and push the button, the program must mark in some color the matched string in the text.

What i do:
- i open QtCreator
- create GUI application Widget and rename it text
- than open ui file and drag-drop the line edit, text edit and Qpushbutton.
My question is: how and where in the header file to introduce the QStringMatcher (if it is the right choice) in order to do the requested function?

Thank you a lot previously.

wysota
17th October 2009, 15:23
my question is mostly general not especially for QStringMatcher.
So why does the title suggest it is about QStringMatcher?


My question is: how and where in the header file to introduce the QStringMatcher (if it is the right choice) in order to do the requested function?

Use QRegExp and a line edit with custom painting. QStringMatcher is tailored for a situation when you compare a pattern against lots of strings (i.e. when searching for something):

This class offers no benefit if you are doing one-off string matches