PDA

View Full Version : Problem with qtconcurrent and signal & slots



angelito870523
18th December 2012, 02:28
My problem is: I have a class that inherits from QObject and a function object for use within the function mapped to run qtconcurrent but is not emitted any signal the threads while it's running. Sorry for my English.

wysota
18th December 2012, 03:09
Please post some code.

angelito870523
19th December 2012, 14:22
This is the function that use mapped


Video* Convertir::convertir(Video *v){
if (!v->getError()) {
QString nombre_fichero = QDir::tempPath()+"/"+QFileInfo(v->getDireccion().path()).fileName();

connect(proceso,SIGNAL(readyReadStandardError()),S LOT(procesarSalida()),Qt::DirectConnection);
connect(this,SIGNAL(valorTotal(int)),v->getProgreso(),SLOT(setMaximum(int)),Qt::DirectConn ection);
connect(this,SIGNAL(valorProgreso(int)),v->getProgreso(),SLOT(setValue(int)),Qt::DirectConnec tion);

QString f_conv = QFileInfo(nombre_fichero).baseName()+"."+formato;
QStringList parametros;
if(formato == "avi" && calidad == "Alta"){
parametros << "-i"<< nombre_fichero << "-sameq" << "-vcodec" << "mpeg2video" << "-y" << salida+f_conv;
}else if(formato == "mpg" && calidad == "Alta"){
parametros << "-i"<< nombre_fichero << "-sameq" << "-y" << salida+f_conv;
}else if(formato == "avi" && calidad == "Baja"){
parametros << "-i"<< nombre_fichero << "-vcodec" << "mpeg2video"<< "-y" << salida+f_conv;
}else
parametros << "-i"<< nombre_fichero << "-y" << salida+f_conv;
proceso->start("ffmpeg",parametros);
}
return v;
}
This is the function object

class Convierte{

public:
typedef Video* result_type;
Video* operator()(Video *v){
Convertir *conv = new Convertir();
conv->convertir(v);
return v;
}
};

The first function belongs to the class Convertir and object function is in the Main Window.
Thanks in advance

wysota
19th December 2012, 17:04
And what signals are not emitted? How do you know they are not emitted?

angelito870523
20th December 2012, 02:29
It does not emit any signals. I tried to use qDebug () to print any message to signal QProcess issued readyReadStandardError, also I emitted any signal in the slot and print any message and nothing. I have no idea. I can not inherit from QObject in the function object because it says that the Q_OBJECT macro is private and can not be copied or something please help me with this. Thank you for your interest.

wysota
20th December 2012, 08:33
It does not emit any signals.
"It" meaning what?


I tried to use qDebug () to print any message to signal QProcess issued readyReadStandardError
Are you expecting anything on stderr?


also I emitted any signal in the slot
I don't see your code emitting any signals.


I can not inherit from QObject in the function object because it says that the Q_OBJECT macro is private and can not be copied or something please help me with this.
Can't help you without seeing the code. I can just assume you were trying to copy a QObject based object.

amleto
22nd December 2012, 12:57
that's a pretty obvious memory leak you have in covierte operator()...