Error while connecting lambda function to QProcess::error

荒凉一梦 提交于 2019-12-05 12:03:06

Problem is that the QProcess has another error() method, so compiler just doesn't know which method use. If you want to deal with overloaded methods, you should use next:

QProcess process;
connect(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>
(&QProcess::error), [=](QProcess::ProcessError pError) {
    qWarning() << "error " << pError;
});
process.start("MyProgram");
process.waitForFinished();

Yes, it looks ugly, but there is no another way (only old syntax?).

This special line tells compiler that you want to use void QProcess::error(QProcess::ProcessError error), so now there is no any ambiguity

More information you can find here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!