Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QMediaPlayer in multithreading env (5.10 CE)
Stanislav Silnicki last edited by
I'm implementing a media (video) player for multi-screen environment. Simultaneous start, etc...
So, I instantiate several threads (Player class: public QThread). In each thread in its run() I create a new QMediaPlayer with nullptr as it's parent QObject. So I assume, that the object exists only in a new thread as soon as it is instantiated within a new thread inside run() func. and has no connection with othre threads ( I know, that QThread obejct itself resides in parent's thread, etc.).
When the first thread (Player) for the first screen is created, nothing interesting is happening. But when exactly same second thread hits CPU, this strange warning appears in error stream:
QObject: Cannot create children for a parent that is in a different thread. (Parent is QObject(0x7fd9ba6d9f20), parent's thread is Player(0x55bc41591c20), current thread is Player(0x55bc41608b20)
Indeed, its only a warning, that doesn't break the functionality, so both players work fine and both screens show proper content.
But what is the nature of this warning? Looks like both instances of QMediaPlayer somehow interferes?