Qt World Summit: Register Today!


QPlainTextEdit autosave to database



  • I have a QPlainTextEdit that retrieves from and sends its modifications to a database. I've connected the textChanged() signal to the database updating routine. Everything works, but efficiency is terrible. The saving routine has to do a read from and a write to the database, so every character entered causes 2 additional queries.

    Is there a way to update the database only after the last textChanged() signal is emitted? Or is there a better way to think out this problem?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    One possible way to do that is to use a QTimer that you reset at each textChanged and that will only trigger the synchronisation when it times out.



  • @SGaist That did it! Thanks for introducing me to QTimer!


Log in to reply