Results 1 to 13 of 13

Thread: Threading...?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Threading...?

    I've been playing with this when I've gotten time during the week, and still no results.

    When you say I should make my thread a member variable, do you mean the declaration of the thread, the actual physical thread itself, or the "connect" command? As far as I could tell according to the QT documentation, I have it set up correctly. If you could tell me what section of my code I should put where, I'd love to try it out.

    The thread has its own class, which is declared in the mainwindowimpl.h file, I dont know how much more global I can get than that.

  2. #2
    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: Threading...?

    Quote Originally Posted by sekatsim View Post
    When you say I should make my thread a member variable, do you mean the declaration of the thread, the actual physical thread itself, or the "connect" command?
    None of these things is a variable. "thread" which appears in post #4 is a variable and it's the one don_simmmel had on mind. Where do you declare it?

  3. #3
    Join Date
    Jun 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Threading...?

    Okay, now I understand. I didnt even consider that, as I'd copied this as close-to-originally as possible from the Mandelbrot example. "thread" was declared in the "private:" of mainwindowimpl. I moved it into "public:", and the program no longer crashes when I enable the joystick.

    However, I still get a "QThread: Destroyed while thread is still running" on enable, and the connect still seems to be failing.

    Where *should* I be declaring "thread"?

  4. #4
    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: Threading...?

    Quote Originally Posted by sekatsim View Post
    Where *should* I be declaring "thread"?
    Making it a member variable is a good solution, provided that the object it's member of will exist longer than the thread runs.

    When exactly do you get that "Destroyed while thread is still running" message?

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

    sekatsim (10th June 2008)

  6. #5
    Join Date
    Jun 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Threading...?

    Thanks, I got it working. I basically just started over from scratch, using the Mandelbrot example, and then gradually modified it to suit my own purposes.

Similar Threads

  1. I'm failing with Threading
    By thomaspu in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2008, 19:40
  2. Threading Issue
    By noufalk in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2007, 13:45
  3. Multi threading ...
    By kiranraj in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2007, 16:51
  4. Threading and plotting graph in same program.
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 9th May 2007, 20:42
  5. Newbie threading question
    By deepayan in forum Qt Programming
    Replies: 17
    Last Post: 16th April 2007, 00:25

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
  •  
Qt is a trademark of The Qt Company.