Unsolved Question about problem with threads in Qt
-
I have never consciously use threads - just what my development environment provides automagically. Hence, I don't have a clue what I might have changed in an application to get the following error from QCoreApplication:
Warning: QCoreApplication: Object event filter cannot be in a different thread. (:0, )
I have used this app quite a lot recently and this is new. I get a bunch of these warning messages just before the program crashes.
Any suggestions about what sorts of things muck up proper threading?
NOTE: See related follow-up question about catching these warnings in the debugger.
-
@drmhkelley said in Question about problem with threads in Qt:
Any suggestions about what sorts of things muck up proper threading?
First: don't use thread if you don't need them
Second: if you use threads make sure you really need them
Third: read the documentation about Qt threads -
@Christian-Ehrlicher - As I said
"I have never consciously use threads - just what my development environment provides automagically. "
My present challenge is the first I've been aware of threads, except as an intellectual construct. How do I figure out why they are being used and how to turn it off?
-
@drmhkelley said in Question about problem with threads in Qt:
How do I figure out why they are being used and how to turn it off?
Since you program your app you should know if you use QThread or QtConcurrent somehwere. If not then you don't have to worry about threads.
-
@Christian-Ehrlicher - I have never used either.
-
Hi,
Are you using an event filter in your application ?
If so, what object are you filtering with it ? -
@SGaist - is "event filter" a technical term"? For a generic meaning of the term, yes I do. Several of my widgets have a protected element "event", which I use to intercept a few events (primarily QKeyEvents). That has be my rather long-standing practice and has presented very few kinks (my recent instance of passing such events directly to QWidget instead of to the current specific widget type is a rare example of a problem).
Since I've been doing this for a while, my present problem must be due to a very recent change - but I haven't yet found anything closely related that has changed. :(
-
No, not at technical term, see QObject::installEventFilter.
-
@drmhkelley said in Question about problem with threads in Qt:
Warning: QCoreApplication: Object event filter cannot be in a different thread. (:0, )
If this message is being produced from Qt code as a warning (which looks to be the case), then assuming you can debug your application you can write a qInstallMessageHandler. Put a breakpoint there and when the message occurs you would get the stack trace. This may help you understand where the message is being issued from.
-
@JonB - as noted in my original post, please see my related post "Trapping QT debugging messages"
-
Strip down your app until it no longer occurs.
-
@drmhkelley said in Question about problem with threads in Qt:
@JonB - as noted in my original post, please see my related post "Trapping QT debugging messages"
See it where? Post a reference.
If it's a Qt code warning, you can get stack trace via
qInstallMessageHandler
. -
@JonB - sorry that was the subject my other post to this forum