Results 1 to 3 of 3

Thread: clear emited signal queue

  1. #1
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default clear emited signal queue

    Hi everyone,
    I am using 3 thread in my program.One is gui thread and rest 2 are non-gui thread(x,y).From one non gui thread(x) i am continuously emitting image to gui thread for display.From that same thread i am also emitting the image to the other non gui thread(y) for some operation.There is a button on gui thread & on click it emits a signal to y.Now i want to do this operation immediately but it is taking time due to all emitted signals are queued.
    Is there any way to clean the queue or increase the priority or any other way to do this?

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: clear emited signal queue

    Hi you have a problem that consumer is slower then producer and you want to ignore some slot calls.
    I suspect that this kind of solution would be for you ok for you.
    Qt Code:
    1. class Consumer ...
    2. {
    3.  
    4. private:
    5. bool processingImage;
    6. QImage image;
    7. };
    8.  
    9. void Consumer::procesImageSlot(QImage newImage)
    10. {
    11. image = newImage; // store data of this call (newest data)
    12. if (processingImage)
    13. return; // ignore this call, slot call is already in progress
    14. processingImage = true; // mark that slot is processed
    15. QApplication::processEvents(); // process remaining slot calls (events) until event queue is empty
    16.  
    17. processImageNow(image);
    18.  
    19. processingImage = false; // mark that processing has ended
    20. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: clear emited signal queue

    thanks
    it is working.

Similar Threads

  1. Clearing the signal queue
    By grabalon in forum Qt Programming
    Replies: 7
    Last Post: 20th May 2010, 23:41
  2. Replies: 2
    Last Post: 20th March 2010, 18:22
  3. how to check if a signal in emited or not??
    By sudhansu in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2009, 08:51
  4. help regarding queue
    By aj2903 in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2009, 07:48
  5. How do I block the signals emited by a widget
    By chikkireddi in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2008, 13:11

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.