Qt inter-process communication-QProcess

Introduction

execute: block running
start:
when the delete process is run asynchronously , the called exe ends the process

Code

Calling process

#include "widget.h"
#include "ui_widget.h"
#include <QProcess>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    
    
    ui->setupUi(this);
}

Widget::~Widget()
{
    
    
    if(m_process != nullptr)
    {
    
    
        delete m_process;
        m_process = nullptr;
    }
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    
    
    m_process = new QProcess(this);
    QStringList list;
    list.append("aaaa");
    m_process->start("test.exe",list);
}

Test process

#include "widget.h"

#include <QApplication>
#include <QtDebug>
#include <QMessageBox>

int main(int argc, char *argv[])
{
    
    
    QApplication a(argc, argv);
    QStringList list = QCoreApplication::arguments();
    qDebug() << list;
    return a.exec();
}

Guess you like

Origin blog.csdn.net/sinat_33859977/article/details/105812750