Results 1 to 9 of 9

Thread: emit qt signal is very slow how it can be optimized?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: emit qt signal is very slow how it can be optimized?

    it's bad idea to use Qt:: DirectConnection between threads, Qt::QueuedConnection must be used.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  2. #2
    Join Date
    Aug 2008
    Posts
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: emit qt signal is very slow how it can be optimized?

    I tried Qt::QueuedConnection and nothing changed.

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: emit qt signal is very slow how it can be optimized?

    yes, because by default last parameter in 'connect' is Qt::AutoConnection, which means
    If the signal is emitted from the thread in which the receiving object lives, the slot is invoked directly, as with Qt:: DirectConnection; otherwise the signal is queued, as with Qt::QueuedConnection.
    try to use customs events, but I think result will not change.
    ps. if you use thread just for loading information and don't transform it then you can you only main thread and use qApp->processEvents() in long time operations.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: emit qt signal is very slow how it can be optimized?

    a) Qt::QueuedConnection is the default for threads. So explicitly specifying it won't change anything.

    b) simple solutions might be
    1. emit the signal not every time but only every 100th time (or so)
    2. just open the file in a normal function call, update the gui and call QCoreApplication::processEvents() now and then
    3. do not use a thread
    4. use a plain callback (do not forget to synchronize access! and don't forget you must not call gui code from another thread!)


    HTH

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  3. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  4. how to know which button emit the signal?
    By coder1985 in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2008, 14:26
  5. emit is slow in Thread?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 2nd August 2007, 08:52

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.