Reputation: 31778
I have a class with the job of running a command line binary and emitting a signal each time stdout is received...however the following code gives a Qt connect
error. What's wrong?
The error:
ffmpegcmd.cpp:39: error: C2665: 'QObject::connect' : none of the 3 overloads could convert all the argument types
C:\Qt\5.3\msvc2013_64\include\QtCore/qobject.h(205): could be 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const'
C:\Qt\5.3\msvc2013_64\include\QtCore/qobject.h(201): or 'QMetaObject::Connection QObject::connect(const QObject *,const QMetaMethod &,const QObject *,const QMetaMethod &,Qt::ConnectionType)'
C:\Qt\5.3\msvc2013_64\include\QtCore/qobject.h(198): or 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'
while trying to match the argument list '(QProcess *, const char *, FFMPEGCMD *const , const char *)'
The class:
bool FFMPEGCMD::runCommand(QStringList parameters)
{
/*
* Enforce one ffmpeg thread per class instance otherwise multiple processes
* will emit signals to the same slot. Make sure running variable is set
* before ffmpeg process is started.
*/
if (this->running)
return false;
this->running = true;
/*
* Run ffmpeg in a new thread, passing signalling it's per line output int
* the output slot for other code to handle output with.
*/
this->process = new QProcess();
this->process->start(this->ffmpeg_binary, parameters);
QObject::connect(this->process, SIGNAL(readyReadStandardOutput()), this, SLOT(ffmpegOutputReady()));
}
/**
* @brief FFMPEGCMD::ffmpegOutput Gets fired when FFMPEG gives an output, emits
* the ffmpeg line
*/
void FFMPEGCMD::ffmpegOutputReady()
{
emit ffmpegLine(this->process->readAllStandardOutput());
}
The header:
class FFMPEGCMD
{
public:
FFMPEGCMD();
bool runCommand(QStringList parameters);
private:
QProcess *process;
bool running;
QString ffmpeg_binary;
private slots:
void ffmpegOutputReady();
public slots:
void ffmpegLine(QString line);
};
Upvotes: 0
Views: 1007
Reputation: 9602
If the code you posted is representative of your actual code then you have the following issues.
class FFMPEGCM
First, you're not inheriting from any Qt classes. You need to at least inherit from QObject
.
class FFMPEGCOM : public QObject
Second, you need to use the Q_OBJECT
macro in your class and make sure the object is being moc'd. This is necessary to create the the slots.
Upvotes: 1