OutWindow::OutWindow(QWidget *parent) :
QMainWindow(parent)
{
setupUi(this);
QtConcurrent::run(this, &OutWindow::startCleaning);
}
void OutWindow::startCleaning()
{
QProcess *processing;
connect(processing,SIGNAL(readyReadStandardOutput()),this,SLOT(readOut()));
QStringList args;
args<<"-c"<<"../wizard/test";
processing->start("bash",args);
processing->waitForFinished();
}
void OutWindow::readOut()
{
// вот здесь нужно добавить в textOutput новую строку вывода processing, то есть
// textOutput->append(processing->readLine());
// но processing не глобальная переменная
}
Если сделать processing глобальным, то получается что я создаю его не в во втором потоке, на что получаю:
Раскрывающийся текст
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x885c4b8), parent's thread is QThread(0x86be250), current thread is QThread(0x8895c28)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x885c4b8), parent's thread is QThread(0x86be250), current thread is QThread(0x8895c28)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x885c4b8), parent's thread is QThread(0x86be250), current thread is QThread(0x8895c28)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x885c4b8), parent's thread is QThread(0x86be250), current thread is QThread(0x8895c28)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QProcess(0x885c4b8), parent's thread is QThread(0x86be250), current thread is QThread(0x8895c28)
Вопрос: как правильно получать вывод процесса запущенного в другом потоке?