Results 1 to 7 of 7

Thread: Problem with qtconcurrent and signal & slots

  1. #1
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Problem with qtconcurrent and signal & slots

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with qtconcurrent and signal & slots

    Please post some code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Problem with qtconcurrent and signal & slots

    This is the function that use mapped

    Qt Code:
    1. Video* Convertir::convertir(Video *v){
    2. if (!v->getError()) {
    3. QString nombre_fichero = QDir::tempPath()+"/"+QFileInfo(v->getDireccion().path()).fileName();
    4.  
    5. connect(proceso,SIGNAL(readyReadStandardError()),SLOT(procesarSalida()),Qt::DirectConnection);
    6. connect(this,SIGNAL(valorTotal(int)),v->getProgreso(),SLOT(setMaximum(int)),Qt::DirectConnection);
    7. connect(this,SIGNAL(valorProgreso(int)),v->getProgreso(),SLOT(setValue(int)),Qt::DirectConnection);
    8.  
    9. QString f_conv = QFileInfo(nombre_fichero).baseName()+"."+formato;
    10. QStringList parametros;
    11. if(formato == "avi" && calidad == "Alta"){
    12. parametros << "-i"<< nombre_fichero << "-sameq" << "-vcodec" << "mpeg2video" << "-y" << salida+f_conv;
    13. }else if(formato == "mpg" && calidad == "Alta"){
    14. parametros << "-i"<< nombre_fichero << "-sameq" << "-y" << salida+f_conv;
    15. }else if(formato == "avi" && calidad == "Baja"){
    16. parametros << "-i"<< nombre_fichero << "-vcodec" << "mpeg2video"<< "-y" << salida+f_conv;
    17. }else
    18. parametros << "-i"<< nombre_fichero << "-y" << salida+f_conv;
    19. proceso->start("ffmpeg",parametros);
    20. }
    21. return v;
    22. }
    To copy to clipboard, switch view to plain text mode 
    This is the function object
    Qt Code:
    1. class Convierte{
    2.  
    3. public:
    4. typedef Video* result_type;
    5. Video* operator()(Video *v){
    6. Convertir *conv = new Convertir();
    7. conv->convertir(v);
    8. return v;
    9. }
    10. };
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with qtconcurrent and signal & slots

    And what signals are not emitted? How do you know they are not emitted?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Problem with qtconcurrent and signal & slots

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with qtconcurrent and signal & slots

    Quote Originally Posted by angelito870523 View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with qtconcurrent and signal & slots

    that's a pretty obvious memory leak you have in covierte operator()...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Problem with Signal and Slots and QThread
    By Informatix in forum Newbie
    Replies: 2
    Last Post: 7th June 2010, 14:21
  2. QThread signal and slots problem
    By mero in forum Qt Programming
    Replies: 8
    Last Post: 8th May 2010, 01:56
  3. Queuing problem with signal and slots
    By montylee in forum Qt Programming
    Replies: 4
    Last Post: 20th November 2009, 06:11
  4. Signal-slots connection problem.
    By impeteperry in forum Qt Tools
    Replies: 26
    Last Post: 23rd January 2007, 14:33
  5. Problem with Signal and Slots
    By Kapil in forum Installation and Deployment
    Replies: 2
    Last Post: 10th February 2006, 08:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.