I solved it! Thank you for your response. Below is the code if someone is interested:
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
{
Q_OBJECT
//here are defined some variables
public:
~mainWindow();
void createUI();
void process();
private slots:
void ReadOutput
(int,
QProcess::ExitStatus);
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
class mainWindow : public QWidget
{
Q_OBJECT
//here are defined some variables
public:
mainWindow(QWidget *parent = 0);
~mainWindow();
void createUI();
void process();
QProcess *process = new QProcess(this);
private slots:
void ReadOutput(int, QProcess::ExitStatus);
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#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(){
//here I create the look of the window
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;
}
#include <QWidget>
#include <QPushButton>
#include <QProcess>
#include <QByteArray>
#include <QTextCodec>
#include <QString>
#include <QDebug>
#include "mainwindow.h"
mainWindow::mainWindow(QWidget *parent) : QWidget(parent)
{
createUI();
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(ReadOutput(int, QProcess::ExitStatus)));
}
mainWindow::~mainWindow()
{
}
void mainWindow::createUI(){
//here I create the look of the window
QPushButton buttonsearch = new QPushButton("Start process", this);
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;
QByteArray a = process->readAllStandardOutput();
QTextCodec* utfCodec = QTextCodec::codecForName("UTF-8");
processStdout = utfCodec->toUnicode(a);
qDebug() << processStdout;
}
To copy to clipboard, switch view to plain text mode
main.cpp
#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();
}
#include <QApplication>
#include "mainwindow.h"
int main(int argl,char *argv[])
{
QApplication app(argl,argv);
mainWindow *window = new mainWindow();
window->setWindowTitle("Test");
window->setFixedSize(700, 335);
window->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks