Results 1 to 18 of 18

Thread: Newbie threading question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,371
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie threading question

    That's exactly what a "queued" connection means.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie threading question

    Yes, I know. It was queued before, but it was treated in the GUI event handler, not in the thread's event handler. That is why it blocked the interface.

    Regards

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,371
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie threading question

    No, it wasn't queued. If you don't pass a connection type to connect() (like it is the case here) it defaults to Qt::AutoConnection, which means that when a signal is emitted and Qt iterates slots that are connected, it checks if the caller and callee live in the same thread. If so, it calls the slot directly (like in this situation). Otherwise it posts an event to the receiving thread.

    BTW. I'm not sure it is reliable to change the thread affinity immediately after calling QThread::start(). The thread may not be started at that point yet. It's safer to move the object on the QThread::started() signal.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie threading question

    True.
    Also, in the Assistant, there is stated:
    With auto connections (the default), the behavior is the same as with direct connections if the signal is emitted in the thread where the receiver lives; otherwise, the behavior is that of a queued connection.
    I'm not sure it is reliable to change the thread affinity immediately after calling QThread::start(). The thread may not be started at that point yet. It's safer to move the object on the QThread::started() signal.
    True.

Similar Threads

  1. Replies: 1
    Last Post: 15th March 2007, 20:45
  2. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38
  3. Tipical newbie question
    By Dark_Tower in forum Newbie
    Replies: 2
    Last Post: 24th March 2006, 06:24
  4. newbie question about qtextedit fields
    By otortos in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2006, 18:21

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.