crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

RazrFalcon
  опции профиля:
сообщение 2.8.2011, 1:20
Сообщение #1


Zombie Mod
*****

Группа: Участник
Сообщений: 1654
Регистрация: 24.5.2010
Из: Харьков
Пользователь №: 1752

Спасибо сказали: 64 раз(а)




Репутация:   212  


Есть:
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)

Вопрос: как правильно получать вывод процесса запущенного в другом потоке?

Сообщение отредактировал RazrFalcon - 2.8.2011, 1:20
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
 
Начать новую тему
Ответов
PAFOS
  опции профиля:
сообщение 2.8.2011, 14:11
Сообщение #2


Активный участник
***

Группа: Участник
Сообщений: 258
Регистрация: 27.12.2010
Из: Дмитров
Пользователь №: 2309

Спасибо сказали: 29 раз(а)




Репутация:   8  


Попробуй так

void OutWindow::readOut()
{
   QProcess* process = static_cast<QProcess*>(sender());
   ...
}
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Сообщений в этой теме


Быстрый ответОтветить в данную темуНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0


RSS Рейтинг@Mail.ru Текстовая версия Сейчас: 4.7.2025, 4:36