Results 1 to 9 of 9

Thread: QThread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread

    In this case you should use a direct connection, otherwise timeout events will be queued in... the main event loop, since MyClass instance belongs to the GUI thread.

  2. #2
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    3
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread

    Jacek, do you mean when he want to use the QTimer and exec() method, he need to connect using Qt:irectConnection in order to let the timer event to be triggered and run in a the same thread as the thread using in run()?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread

    Quote Originally Posted by ball
    do you mean when he want to use the QTimer and exec() method, he need to connect using Qt:irectConnection in order to let the timer event to be triggered and run in a the same thread as the thread using in run()?
    Yes, that's what I meant.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QThread

    Sorry guys,
    I don't got it. (using DirectConnection)
    The stange thing is that the first variant works fine.
    I thought that getting a timer to trigger the work instead of a wait would be a little more elegant. But the timer way doesn't work. I don't get any messages that the connect() doesn't work.

    note also (although perhaps beside the point): I have emits in the update() func and they work fine into the gui thread.

    any ideas?

    thanks
    K

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread

    Quote Originally Posted by TheKedge
    But the timer way doesn't work.
    How did you start it?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QThread

    I call
    start()
    from the constructor of my class. Or more precisely, I have an init() func called a single shot timer in the constructor. Thus:
    QTimer::singleShot(0, this, SLOT(init()));

    start() is called from the init() func.

    As said, the thread is running -> the loop/sleep method works. But I have the feeling somethings not right with the connect() (although I don't get any error messages)
    K

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread

    Does it work with queued connection?

  8. The following user says thank you to jacek for this useful post:

    TheKedge (25th August 2006)

Similar Threads

  1. How can I get the thread ID out of QThread
    By Artschi in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2017, 03:27
  2. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 11:19
  3. Posting custom events to a subclass of QThread
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2006, 15:49
  4. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51
  5. QProcess in a QThread
    By chombium in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 15: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.