Qt QProcess信号 使用lambda表达式链接qt信号

使用lambda表达式链接qt信号
connect(process, &QProcess::readyReadStandardOutput, [&]() {
        while (process->canReadLine()) {
            std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx output" << process->readLine().toStdString() << std::endl;
        }
    });
    connect(process, &QProcess::readyReadStandardError, [&]() {
        while (process->canReadLine()) {
            std::cout << "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY error" << process->readLine().toStdString() << std::endl;
        }
    });
    connect(process, &QProcess::started, [&]() {
        std::cout << "QProcess start~~~" << std::endl;
    });

    connect(process, &QProcess::errorOccurred, [&]() {
        std::cout << "errorOccurred" << std::endl;
    });

//    connect(process, &QProcess::finished, [=](int exitCode, QProcess::ExitStatus exitStatus) {
//        std::cout << "errorOccurred" << std::endl;
//    });

    connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
            [=](int exitCode, QProcess::ExitStatus exitStatus) {});

转载于:https://my.oschina.net/u/3707404/blog/3070281

你可能感兴趣的:(Qt QProcess信号 使用lambda表达式链接qt信号)