[Solved] QTextEdit::undo or QTextDocument::undo

  • Hi everybody.

    I'm new to Qt and reading some books.
    One of the books I read, there is a text editor example.

    Somewhere in the code, the author uses


    for an undo operation where document() returns a QTextDocument object.
    However, I realized that QTextEdit already has an undo function and does the same thing.
    Now, sorry for that easy question but is there a difference between them ?

  • Lifetime Qt Champion

    High and welcome to devnet,

    QTextEdit's undo will do some internal stuff and call undo on it's document. Calling undo directly on the document will by-pass QTextEdit's internal handling.

    Hope it helps

  • Thank you for your reply.
    It is clearer now.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.