我在 Qt 构建中遇到了同样的错误。
我正在为 从 Qprocess完成的信号添加一个插槽 - 上面的文档说:
void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus)
我的代码:
自由声音.h
void slotPreviewFinished(int exitCode, QProcess::ExitStatus exitStatus);
自由之声.cpp
m_previewProcess = new(Qprocess);
connect (m_previewProcess ,SIGNAL (finished(int , QProcess::ExitStatus )),this,SLOT(slotPreviewFinished(int , QProcess::ExitStatus)));
void slotPreviewFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qDebug()<<"// slotPreviewFinished: "<<exitCode;
}
编译上面生成的:/home/ttguy/kdenlive/kdenlive_git/build-kdenlive-Desktop-Default/src/moc_freesound.cpp:121:错误:未定义引用`FreeSound::slotPreviewFinished(int, QProcess::ExitStatus)'
解决方法是在我的 slotPreviewFinished 实现前加上 FreeSound::
void FreeSound::slotPreviewFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qDebug()<<"// slotPreviewFinished: "<<exitCode;
}