Results 1 to 6 of 6

Thread: The right approach to "ask" data to the running thread..

Threaded View

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

    Default Re: The right approach to "ask" data to the running thread..

    Did you start the thread event loop with exec()? In this case you can send a signal from the GUI thread to the worker thread, basically telling it you need some data. Then the worker thread will send a signal to the GUI thread, with some parameters. This is the safest way.

    If you didn't start the event loop and don't want to redesign your code now, then you must have an endless loop in your thread's run method. But you'll have to post some code, or at least describe the way you do things better.

    The problem is that it doesn't work .. when I am inside a function of the model thread ( a QThread derived class) called from the GUI I got different values than if I run the same function from the normal model "path".. like they are different instances, or ??...
    In that function, do you perform some specific thread processing? Because the function will be executed the GUI thread context. This could explain why the members/variables are messed up.

    and happy 2008
    You too.

  2. The following user says thank you to marcel for this useful post:

    sylvaticus (1st January 2008)

Similar Threads

  1. Accessing data from a worker thread
    By steg90 in forum Qt Programming
    Replies: 20
    Last Post: 25th May 2007, 10:20
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  3. QThread: Destroyed while thread is still running
    By Shuchi Agrawal in forum Newbie
    Replies: 8
    Last Post: 3rd April 2007, 06:27
  4. Replies: 10
    Last Post: 20th March 2007, 22:19

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.