使用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) {});