Results 1 to 2 of 2

Thread: Producuer Consumers GUI app with circular buffer

  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Producuer Consumers GUI app with circular buffer

    Hello, I'm trying to write GUI multithreading application on PyQt, but with no luck . Can anyone could write sample code how to make produce and consumer threads work with GUI.
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Producuer Consumers GUI app with circular buffer

    Create a producer class, call it "Producer" and inherit it from QObject.
    Implement it.

    Create a consumer class, call it "Consumer" and inherit it from QObject
    Implement it.

    Create an object based on the the Producer class, call it "producerObject".
    Create one or more objects based on the Consumer class. In case of one consumer, call it "consumerObject".

    Establish the communication between the objects, the easiest way is to use signals and slots I guess.

    Create a QThread object for each Producer or Consumer object.
    Example: producerThread and consumerThread.

    Move the producerObject to the producerThread (see QObject::moveToThread)
    Do the same with the consumerObject.

    In c++, assuming both producerObject and producerThread are pointers:
    Qt Code:
    1. producerObject->moverToThread(producerThread);
    To copy to clipboard, switch view to plain text mode 

    Start the producerThread and the consumerThread.

    Use the signals and slots to do something useful. Both the producer and consumer will run in separate threads and the gui will be run in the main thread.

Similar Threads

  1. circular buttons
    By moabi in forum Newbie
    Replies: 2
    Last Post: 18th March 2010, 04:28
  2. 1 producer 14 Consumers problem
    By tsyahoo in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2009, 20:24
  3. Circular scale
    By fruzzo in forum Qwt
    Replies: 1
    Last Post: 6th March 2008, 07:20
  4. QSemaphore: 1 Producer, 3 Consumers
    By Daedalus in forum Newbie
    Replies: 9
    Last Post: 1st April 2007, 20:59
  5. Is there a circular reference here?
    By rh in forum General Programming
    Replies: 3
    Last Post: 22nd January 2006, 21:51

Tags for this Thread

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.