Important: Please read the Qt Code of Conduct -

Text checker (based on criteria)

  • I just want some opinions on what is the best way to implements this. As I'm a newbie to Qt I don't know all that Qt can offer. I searched the web to no avail.
    Example of usage: I paste text into the program, click check (checking on some criteria) and then it tells me where and what is the problem, ideally it colors the words that are bad.
    QTextEdit? How do I find specific words, color them and replace them?
    I need some ideas please.

  • Yes, QTextEdit is the right component to start with. For the formatting, look at the documentation what QTextCursor and QTextDocument can do (especially QTextCursor::setCharFormat).
    With the text cursor, you could also do the iterating e.g. over words. Alternatively you could get the plain text as a QString (QTextEdit::toPlainText) and analyze that.

    In general, the Qt Documentation is great for actually learning about functionality.

    //EDIT: A thing that often confuses beginners: the QTextCursor in text documents is not to be understood as the graphical bar that blinks on the user's screen. It is the programmatic interface to the text structure and formatting that – in function and usage concept – resembles the text cursor paradigm.

  • Thank you for your swift response. I will check the documentation. I just wanted to know if it's the right component to start with.

Log in to reply