Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Debug Mode Thread Issue
When I run my project in Debug Mode I am getting this following Error.
Warning (default): :0 (in ): QObject: Cannot create children for a parent that is in a different thread.
(Parent is QmlUiLoggerPlugin(0x7fffe005aab0), parent's thread is QThread(0x686660), current thread is QThread(0x630c40)
Debugging has finished
This error only happens when i run in Debug Mode . In Release mode the project runs fine.
I am using Qt 5.7 and CMake.
Any help would be appreciated.
Its a warning only.
Is this a QML project?
But should also happen in release.
Maybe it just dont warnings error in release?
Thanks for the quick response.
Yes its a qml project .
Theoretically this should also happen in release, BUT ITS NOT. Even though its a warning, the debugger exits automatically.
Ok, i mostly seen this warning with c++ and using QThread.
Do you have your own threads or anything that could cause this?
Release might (most probably) suppress those kind of warnings. Do you know which object generates the warning? From the looks of it you're trying to add an object that lives in a (worker) thread to QML, which runs in the GUI thread.
@mrjj , A small correction , Its a both C++ and QML Project. C++ acts as a backed. And Yes the error is caused by a C++ Class.
TopNotch_Mach07 last edited by TopNotch_Mach07
@kshegunov If its issue of the thread. It should happen in the release build also right ? doesn’t it ?
And error throws up at line which is bold and italicised
static QQuickWindow *setupMainWindow(QQmlEngine *engine, const QString &mainFile)
QQmlComponent rootComponent(engine, QUrl(mainFile));
If its issue of the thread. It should happen in the release build also right ? doesn’t it ?
It probably does, Qt might not issue the warning though, as it is release, i.e. production code.
Well, apparently you call
setupMainWindowfrom a thread different than the one that created
QQmlEngine). How and why though, you should trace through your code.
Finally I am able to some how solve the issue without completely understanding it.
There were 5 threads running in the Qt , I had put a break point on the code just one line before where it generates the Warning . After that I switched to different thread other than the default one and then I hit continue button in the debugger. Voila ! ! it worked.
Thanks for all the help and suggestions.