Results 1 to 7 of 7

Thread: Signals and Slots

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default Signals and Slots

    Hello,

    in my app I have a custom class for networking that uses a QNetworkAccessManager object inside it.
    From the QNetworkAccessManager's requestFinished(..) slot I emit some custom signal that carries some data
    and which I want to handle in other classes.

    My problem is following. Imagine in some class B, I tie a slot to the signal I mentioned above.
    Then I tie another slot to this signal. In the end we may have that to my signal (customSignal) there are
    10 slots connected in some other class B. I don't want that once the signal is emitted all these
    10 slots get called simultaneously. Rather at some point in time, I want the signal to call
    only one slot, at another point in time, only another slot and etc.

    How can I achieve this?

    I know I could for example use different my custom network objects (but I was told it is not recommended??).
    e.g., like this:

    Qt Code:
    1. MyNetworkClass *network1 = new MyNetworkClass();
    2. bool res = QObject::connect(network1, SIGNAL(signalSuccess(QVariant)), this, SLOT(CustomSLot1(QVariant)));
    3.  
    4. MyNetworkClass *network2 = new MyNetworkClass();
    5. bool res = QObject::connect(network2, SIGNAL(signalSuccess(QVariant)), this, SLOT(CustomSLot2(QVariant)));
    6.  
    7. MyNetworkClass *network3 = new MyNetworkClass();
    8. bool res = QObject::connect(network3, SIGNAL(signalSuccess(QVariant)), this, SLOT(CustomSLot3(QVariant)));
    To copy to clipboard, switch view to plain text mode 

    I think it would work this way also??? Thanks.
    Last edited by ggdev001; 20th February 2013 at 07:06.

Similar Threads

  1. Connecting QML signals with Qt slots
    By KIBSOFT in forum Qt Quick
    Replies: 1
    Last Post: 15th November 2010, 09:18
  2. Replies: 8
    Last Post: 18th July 2009, 15:57
  3. Connecting signals and slots help pls
    By bod in forum Qt Programming
    Replies: 9
    Last Post: 1st July 2008, 15:01
  4. problem with connecting signals with slots"
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2007, 16:44
  5. Connecting signals & slots across different threads
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 12:40

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.