samedi 1 décembre 2018

Display non-const string (error message) in Qt

Recently, I had to code some kind of input validation in a Qt GUI project.
During a failing validation process, I would like to inform the user what exactly went wrong. Hence, I created QMessageBoxes with a short summary and the detailed error message gained by std::exception::what().

Alas, QMessageBoxes get constant strings, but exception::what() returns a non-constant C-like string.

What is the best way to solve / circumvent this issue? I need a temporary conventional widget with the ability to display a runtime error message non-editable, but preferably copyable. Perhaps, QMessageBox is not the best candidate for doing this?

Due to exterior constraints, I am using Qt 5.7 with C++ 11 and without Qt Quick.

Aucun commentaire:

Enregistrer un commentaire