Container::Container(QObject *parent) : QObject(parent) , m_workersThread(new QThread){ m_workersThread->start(); QObject::connect(m_workersThread, &QThread::started, this, &Container::run); QObject::connect(this, &Container::ready, this, &QObject::deleteLater);}void Container::run(){ for (int i = 0; i < 3; ++i) { Worker* worker = new Worker; QObject::connect(this, &QObject::destroyed, worker, &QObject::deleteLater); worker->moveToThread(m_workersThread); m_workers.push_back(worker); } emit ready();}Worker::Worker(QObject *parent) : QObject(parent){}Worker::~Worker(){ qDebug() << "destroy";}
C++ (Qt)class MyClass {... SomeClass m_data; // этот член переносится в др поток};