Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

multiple main windows



  • I'm trying to write a program using QT windows and an API which uses PubNub notifications. The program should run in the background until a notification, then either open a new QT window or modify an existing QT window. I've tried this a couple different ways but I keep getting errors like the one below

    QObject: Cannot create children for a parent that is in a different thread.

    Any advise would be appreciated



  • @andocromn
    Don't use threads unless you really, really need to. If you do, you need to understand Qt threading thoroughly. The error message tells you which restriction of threading you are breaking.



  • @JonB I believe it is the ringcentral API that I am using, which uses threading. do you know if there is any way to create QT windows within a thread?



  • @andocromn
    For Qt you must only do UI operations in the main thread. You must not so something like "create a window in another thread". [EDIT To be fair there is QObject::moveToThread(QThread *targetThread). So I shouldn't quite say what I did. But your error is for this reason.]



  • @JonB Understood, thank you for commenting and explaining. I was starting to wonder if it was a compatibility issue between QT and this API's code


Log in to reply