Hello! I don't get how to run a QProcess with QThread. Please help me, I tried also with both worker class and run() method but it doesn't work. I get: "QThread: desztroyed while thread is still running".
Here is my code:

mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QWidget>
  5. class mainWindow : public QWidget
  6. {
  7. Q_OBJECT
  8. //here are defined some variables
  9. public:
  10. mainWindow(QWidget *parent = 0);
  11. ~mainWindow();
  12. void createUI();
  13. void process();
  14. };
  15. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include <QWidget>
  2. #include <QPushButton>
  3. #include <QProcess>
  4. #include <QByteArray>
  5. #include <QTextCodec>
  6. #include <QString>
  7. #include <QDebug>
  8. #include "mainwindow.h"
  9.  
  10. mainWindow::mainWindow(QWidget *parent) : QWidget(parent)
  11. {
  12. createUI();
  13. }
  14.  
  15.  
  16. mainWindow::~mainWindow()
  17. {
  18.  
  19. }
  20. void mainWindow::createUI(){
  21. //here I create the look of the window
  22. QPushButton buttonsearch = new QPushButton("Start process", this);
  23. buttonsearch->setToolTip("Start process");
  24. buttonsearch->setGeometry(200, 290, 100, 30);
  25. connect(buttonsearch, &QPushButton::clicked, [this]() {process(); });
  26. }
  27.  
  28. void mainWindow::process(){
  29. process->setProcessChannelMode(QProcess::MergedChannels);
  30. process->start("\"D:\\YTDownloader\\youtube-dl.exe\" -e --no-playlist https://www.youtube.com/watch?v=6V-wwfuxZxw");
  31. process->waitForReadyRead();
  32. QByteArray a = process->readAllStandardOutput();
  33. QTextCodec* utfCodec = QTextCodec::codecForName("UTF-8");
  34. QString processStdout = utfCodec->toUnicode(a);
  35. qDebug() << processStdout;
  36. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argl,char *argv[])
  5. {
  6. QApplication app(argl,argv);
  7.  
  8. mainWindow *window = new mainWindow();
  9. window->setWindowTitle("Test");
  10. window->setFixedSize(700, 335);
  11. window->show();
  12.  
  13. return app.exec();
  14. }
To copy to clipboard, switch view to plain text mode 

I try to run process() function into a thread when buttonsearch is clicked. Thank you for your help!