Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Extend qDebug, qWarning ... with my own qSomething
I am looking for a smart and simple way to handle thread-safe info and warning QMessageBox popup with a macro.
I would like to be able to call qInformUser("msg") or qWarnUser("msg") and if possible qAskUser("msg", returnedButton) from any thread and trigger a popup, a printf in the stdout and a new entry in a widget.
I (ab)use qDebug & co a lot in my code.
I have installed a message handler and it's been easy to redirect messages in the console, or in a widget. I can also disable the messageboxes on user request. I am now wondering how I could do to:
- add a qInfo that just give user information without any scary "warning" icon
- add a qQuestion that can return a boolean
and keep the same flexibility as with built in macros.
Thanks in advance for any piece of advice.
dangelog last edited by
That's abusing of the QDebug functionality, which is primarly to report stuff relevant for the developer, not for the user. Can't you use QMessageBox for your use cases?
Chris H last edited by
There is nothing magical about qDebug(): it's basically just a class that implements operator<< and plays nice with all of Qt's data types. If you just want your own class that implements operator<< and instead of printing something out fires off a signal it should be straightforward.
goetz last edited by
"Qxt":http://dev.libqxt.org/libqxt/wiki/Home, a free extension library for Qt, provides a logger framework. Maybe it is of use for you.
Scylla last edited by
I also can recommend the logger framework from qxt.
Thanks for the hint.
Do you think qxt logger can easily be extended to handle returned values from the popped message boxes?
Scylla last edited by
bq. Do you think qxt logger can easily be extended to handle returned values from the popped message boxes?
I didn't get your question! You set the text to message boxes, so you can put the same text to the logger, isn't it!
The logger is static so you can access the same logger everywhere.
Ok I think it is not the first time I do not express correctly what I am trying to do.
I edited the first post. Tell me if it is not clear.