Results 1 to 3 of 3

Thread: How to force the run() function to execute first

  1. #1
    Join Date
    Sep 2017
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to force the run() function to execute first

    Hi ,

    I have below code where I see that the run function of the clientThread runs after the serverConnect() function. How can I force the run() function to execute first before serverConnect.

    Thank you,

    `
    Qt Code:
    1. clientThread->start();
    2.  
    3. /* Connect to the notification server. */
    4. clientThread->serverConnect();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to force the run() function to execute first

    Hi,

    You can use the SIGNAL "started" to a SLOT and in this SLOT call the other function.

    Qt Code:
    1. connect(clientThread,SIGNAL(started()),this,SLOT(myThreadStarted()));
    2. clientThread->start();
    3.  
    4. void myClass::myThreadStarted()
    5. {
    6. clientThread->serverConnect();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Òscar Llarch i Galán

  3. #3
    Join Date
    Sep 2017
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to force the run() function to execute first

    It worked, Thanks for help!

Similar Threads

  1. execute build-in javascript function
    By TorAn in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2016, 13:53
  2. Lua + C++ Function Execute
    By steadi in forum Newbie
    Replies: 1
    Last Post: 2nd December 2012, 17:44
  3. Replies: 2
    Last Post: 6th December 2010, 21:36
  4. Qt Creator Force Stop
    By Azraiyl in forum Qt Tools
    Replies: 5
    Last Post: 16th November 2010, 13:22
  5. how to force an exiting?
    By anli in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2006, 12:36

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.