Results 1 to 4 of 4

Thread: Running an external function in a new thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Running an external function in a new thread

    If you want to use your existing function in new thread, it will not work as it is, because this function modifies GUI objects (QLabel in you case), as you earlier said.

    One important thing to remember when creating new thread in Qt, is never access the GUI objects from new thread, GUI objects should always be in main GUI thread.

    So, you need to modify your external function, and separate GUI and logic part of it, then put the logic part of it in the new thread, and put the GUI part of it in the main GUI thread. Then the last thing is to connect you logic to your GUI, that should be straight forward it know how to use signals and slots.

    Check this example ThreadTest.zip
    Last edited by Santosh Reddy; 29th May 2011 at 04:54. Reason: updated contents

Similar Threads

  1. Replies: 2
    Last Post: 5th August 2010, 10:18
  2. Replies: 10
    Last Post: 1st July 2010, 10:59
  3. Replies: 5
    Last Post: 17th March 2010, 18:30
  4. External libary in a separate thread: is this correct?
    By sylvaticus in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2009, 08:47
  5. running external applications via QT?
    By cruisx in forum Newbie
    Replies: 1
    Last Post: 11th August 2009, 06:34

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.