While running my Qt5 project, I get warnings such as
QObject::startTimer: Timers cannot be started from another thread
and others.
While many answers cover what in a given code caused these warnings, or how to correct them, I would like to know where in the code was the warning generated, a traceback.
This is because I think it is being caused by my incorrect usage of some Qt functionality that causes warnings internally, such as, in the above case, functionality that uses timers to execute. Knowing the line number would be helpful for debugging, but unfortunately that is not shown, even in debug mode.
Is there a way to do this?
This question seems to be almost identical, but I am not observing anything similar to what is posted in the question there - I don't see any line numbers. I didn't understand how to apply the answer there, if applicable.
Thank you.
nwp, in the comments, pointed out this answer by Nawaz, which works great when I put a break point on the warning message line, here:
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); //break point here
break;
This gives a proper traceback when running in the debugger mode, as I needed.