The question was not trivial. The method specified below worked, for a single-threaded program, in a multi-threaded pause fails. Please tell me the correct option.

class Sleep: public QThread { public: static void msleep(int ms) { QThread::msleep(ms); } }; ... Sleep::msleep(1000); ... 

Further, the approximate architecture of my application:

 int main(int argc, char *argv[]) { QApplication a(argc, argv); ... TransportMail *tm = new TransportMail(); TaskThred thredTm; tm->moveToThread(&thredTm); thredTm.start(); ... } void TransportMail::sendMail(QString mail) { ... sleep(10); // не работает ... } 

    1 answer 1

    The msleep function that is proposed in your program suspends only the thread in which it runs. If you want to suspend the entire program, execute this function in each stream you want to suspend. You can suspend a particular thread by calling hThread->msleep(10); .

    • Probably you meant that I first need to get a pointer to my stream, I have a problem with this while I am doing my decision. Sleep function :: msleep (1000); stops the whole program if it is single-threaded, otherwise it does not affect the stream in which it is running. - shaman888