Results 1 to 3 of 3

Thread: is it possible to set priority for the slots which connected to an object?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Question is it possible to set priority for the slots which connected to an object?

    Hi, All

    is it possible to set priority for the slots which connected to an object?
    for example:

    Qt Code:
    1. myaction = new QAction(this);
    2. connect(myaction,SIGNAL(triggered()),this,SLOT(do_thing1()));
    3. connect(myaction,SIGNAL(triggered()),view_,SLOT(do_thing2)));
    To copy to clipboard, switch view to plain text mode 

    I hope when the action is active , do_thing1 will be called first ,then call view_::do_thing2
    but the problem is that I found view_::do_thing2 will be called first sometimes

    this can solved by write another slot ,such as do_things:
    void do_things()
    {
    do_thing1();
    view_->do_thing2();
    }

    but I am still want to know if there is a way to control the calling sequence of the slots that connect to an object.

    Thanks in advance,
    Best regards,
    hb

  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: is it possible to set priority for the slots which connected to an object?

    Use queued connections

  3. The following user says thank you to tbscope for this useful post:

    hashb (16th September 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: is it possible to set priority for the slots which connected to an object?

    I remembered that the slots are called in an arbitrary order, like hashb noticed. But I stumbled across
    If a signal is connected to several slots, the slots are activated in the same order as the order the connection was made, when the signal is emitted.
    at QObject::connect(). Strange.

  5. The following user says thank you to Lykurg for this useful post:

    hashb (16th September 2010)

Similar Threads

  1. Replies: 3
    Last Post: 30th July 2010, 16:34
  2. how can i know how many slots connected to a signal?
    By yj_yulin in forum Qt Programming
    Replies: 6
    Last Post: 1st December 2008, 10:24
  3. Auto-connecting slots for object *this*?
    By hickscorp in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2007, 14:22
  4. priority of QThread
    By quickNitin in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2006, 12:53
  5. Emiting signal, which NOT connected to any slots
    By krivenok in forum Qt Programming
    Replies: 7
    Last Post: 27th February 2006, 16:32

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.