3 Attachment(s)
App dissapears from Task Manager when running a QProcess
Hello! I have a problem. When I run a QProcess for the first time, my app is shown in Task Manager with all processes.
Attachment 13261
When I run the same QProcess second time my app dissapears from Task Manager.
Attachment 13262
When the QProcess is finished after started second time, app is shown again in Task Manager but without its process.
Attachment 13263
My code:
mainwindow.h
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
{
Q_OBJECT
public:
~mainWindow();
void createUI();
void process();
private slots:
void ReadOutput
(int,
QProcess::ExitStatus);
};
#endif // MAINWINDOW_H
mainwindow.cpp
Code:
#include <QWidget>
#include <QPushButton>
#include <QProcess>
#include <QByteArray>
#include <QTextCodec>
#include <QString>
#include <QDebug>
#include "mainwindow.h"
{
createUI();
connect(process,
SIGNAL(finished
(int,
QProcess::ExitStatus)),
this,
SLOT(ReadOutput
(int,
QProcess::ExitStatus)));
}
mainWindow::~mainWindow()
{
}
void mainWindow::createUI(){
buttonsearch->setToolTip("Start process");
buttonsearch->setGeometry(200, 290, 100, 30);
connect(buttonsearch, &QPushButton::clicked, [this]() {process(); });
}
void mainWindow::process(){
process
->setProcessChannelMode
(QProcess::MergedChannels);
process->start("\"D:\\YTDownloader\\youtube-dl.exe\" -e --no-playlist https://www.youtube.com/watch?v=6V-wwfuxZxw");
void readOutput
(int exitCode,
QProcess::ExitStatus exitStatus
){ qDebug() << exitCode;
qDebug() << exitStatus;
processStdout = utfCodec->toUnicode(a);
qDebug() << processStdout;
}
main.cpp
Code:
#include <QApplication>
#include "mainwindow.h"
int main(int argl,char *argv[])
{
mainWindow *window = new mainWindow();
window->setWindowTitle("Test");
window->setFixedSize(700, 335);
window->show();
return app.exec();
}
How can this be solved? Thank you!
Re: App dissapears from Task Manager when running a QProcess
It may not be the reason, but you are calling QProcess::start() incorrectly. The preferred way is to specify the first argument as a QString containing the name of the program to be executed (your youtube-dl.exe), and the second argument a QStringList where each item in the list is one of the individual command line arguments. In your case, this should be:
Code:
QString program
= "D:\\YTDownloader\\youtube-dl.exe";
args << "-e" << "--no-playlist" << "https://www.youtube.com/watch?v=6V-wwfuxZxw";
process->start( program, args );
Also, Task Manager has a default update rate. (View->Update speed) If your process starts and ends in less time than the update interval, it may not show up.
Re: App dissapears from Task Manager when running a QProcess
Quote:
Originally Posted by
d_stranz
It may not be the reason, but you are calling
QProcess::start() incorrectly. The preferred way is to specify the first argument as a QString containing the name of the program to be executed (your youtube-dl.exe), and the second argument a QStringList where each item in the list is one of the individual command line arguments. In your case, this should be:
Code:
QString program
= "D:\\YTDownloader\\youtube-dl.exe";
args << "-e" << "--no-playlist" << "https://www.youtube.com/watch?v=6V-wwfuxZxw";
process->start( program, args );
Also, Task Manager has a default update rate. (View->Update speed) If your process starts and ends in less time than the update interval, it may not show up.
Thank you very much!