QT,无法将 QProcess::finished(int,QProcess::ExitStatus) 信号绑定到 lambda

QT, can't bind QProcess::finished(int,QProcess::ExitStatus) signal to lambda

我正在使用 c++11 和 QT 5.12。
我正在尝试将 QProcess::finished(int,QProcess::ExitCode) 信号连接到 lambda,但使用代码

QProcess PlayerProcess;
connect(PlayerProcess, &QProcess::finished,
[=](int exitCode, QProcess::ExitStatus exitStatus)
{
 //  Function body
}

编译器说

../Qt/5.12.1/gcc_64/include/QtCore/qobject.h:300:13: note:   no known conversion for argument 1 from ‘QProcess’ to ‘const Object* {aka const QProcess*}’
../Qt/5.12.1/gcc_64/include/QtCore/qobject.h:308:13: note: candidate: template<class Func1, class Func2> static typename std::enable_if<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1), QMetaObject::Connection>::type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const QObject*, Func2, Qt::ConnectionType)
             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
             ^~~~~~~
../Qt/5.12.1/gcc_64/include/QtCore/qobject.h:308:13: note:   template argument deduction/substitution failed:
../Launcher/mainwindow.cpp:184:9: note:   candidate expects 5 arguments, 3 provided
         );

Google 了一下,我能找到的唯一相关问题是 MainWindow class 不是从 QObject 派生的(但我的 MainWindow 是从 QWidget 派生的 QMainWindow 派生的),或者编译器无法'解决重载的 QProcess::finished 信号(可以是 (int) 或 (int,QProcess::ExitCode),但为此我尝试了我能找到的两种快速修复:

void  (QProcess::* mySignal)(int, QProcess::ExitStatus) = &QProcess::finished;
auto mySignal2 = QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished);

但同时使用编译器错误并没有改变。

我错过了什么?

提前致谢。

正如@ymoreau 所说,QObject::connect 函数需要参数作为指针,所以我用 &PlayerProcess 更改了连接的第一个参数。

然后,使用两个显式重载之一解决了重载 QProcess::finished 问题。