Results 1 to 8 of 8

Thread: Slots & Signals w/ parameters passed by reference.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Location
    Colorado
    Posts
    12
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Slots & Signals w/ parameters passed by reference.

    I'm working on a (1) object that is needs to signal another (2) object that some data is ready for processing. But I need to distinguish if the (2) object needs to initialize how the data is processed for the first time. I had thought that I could pass a boolean value via pass-by-reference and then allow the slot to change it so when some more data is ready to be processed the slot wouldn't initialize it the second time around.

    Example Code:

    Qt Code:
    1. connect(this, SIGNAL(readySendData(bool &, MyData &)),
    2. this, SLOT(sendData(bool &, MyData &)));
    3.  
    4.  
    5. void DataProcessor::sendData(bool & intializationNeeded, MyData & data)
    6. {
    7. if(intializationNeeded)
    8. {
    9. // Do Initialization Stuff
    10. intializationNeeded = false;
    11. }
    12. else
    13. {
    14. // Do Stuff
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 


    Hopefully this is clear but I would like to check to see if initialization is needed. Then the slot will change the parameter from true to false. So then next time the signal readySendData is generated it will enter the else code block. Is this possible with Slots and Signals or does it violate the loose coupling scheme.
    Last edited by jpn; 18th December 2008 at 22:12. Reason: missing [code] tags

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15

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
  •  
Qt is a trademark of The Qt Company.