1

Topic: The cycle of messages in a separate flow

Good evening! So it turned out that it is necessary to work at once with two libraries One of them - "locking", that is operation of functions is fulfilled in the same flow, occupies the durable time and consequently the code needs to be allocated in a separate flow. Plus is still some reasons to allocate the code in a separate flow. The second is calculated for operation in a surrounding of a cycle of messages Qt. That is if is qt-shnoe a window it is possible to cause a method of this library, it will do something in a background (at this time it is possible to work with a window, it "does not hang"), and on termination of object of library causes some slot in a class of this window, in advance connected to an appropriate signal. A question - and how it to combine? I will accept layout in a flow of a certain "own" cycle of messages which start up to itself is twisted (actually at me there is a whole class inherited from QObject in which all it and happens). Let the cycle of messages causes as required slots of the same class. Which, working with the first library, will initiate again operation of the second and to return control in a cycle of messages. Simultaneous operation of both libraries even is not necessary. To allocate the code in different flows it would not be desirable, in the first it complicates logic, in the second it would not be desirable to anchor the code to windows and gui generally. A question - whether it is possible in Qt to organize the cycle of messages and how it to make?

2

Re: The cycle of messages in a separate flow

Hello, coder9999, you wrote: a C> Good evening! A C> So it turned out that it is necessary to work at once with two libraries of a C> One of them - "locking", that is operation of functions is fulfilled in the same flow, occupies the durable time and consequently the code needs to be allocated in a separate flow. Plus is still some reasons to allocate the code in a separate flow. The flow should be one? Whether it is possible to do simply each call from a separate new flow? A C> the Second is calculated for operation in a surrounding of a cycle of messages Qt. That is if is qt-shnoe a window it is possible to cause a method of this library, it will do something in a background (at this time it is possible to work with a window, it "does not hang"), and on termination of object of library causes some slot in a class of this window, in advance connected to an appropriate signal. If you from a library flow send a signal which will be accepted Qt-shnym by a flow the operation cycle of messages for this purpose is not necessary to you. C> the Question - and how it to combine? I will accept layout in a flow of a certain "own" cycle of messages which start up to itself is twisted (actually at me there is a whole class inherited from QObject in which all it and happens). Let the cycle of messages causes as required slots of the same class. Which, working with the first library, will initiate again operation of the second and to return control in a cycle of messages. What for the own? Create separate QThread, then move to it the QObject which works with library. That will do. A C> Simultaneous operation of both libraries even is not necessary. To allocate the code in different flows it would not be desirable, in the first it complicates logic, in the second it would not be desirable to anchor the code to windows and gui generally. A C> the Question - whether it is possible in Qt to organize the cycle of messages and how it to make? Look here at this example.

3

Re: The cycle of messages in a separate flow

Hello, coder9999, you wrote: a C> Good evening! A C> So it turned out that it is necessary to work at once with two libraries of a C> the Question - and how it to combine? I will accept layout in a flow of a certain "own" cycle of messages which start up to itself is twisted (actually at me there is a whole class inherited from QObject in which all it and happens). Let the cycle of messages causes as required slots of the same class. Which, working with the first library, will initiate again operation of the second and to return control in a cycle of messages. A C> Simultaneous operation of both libraries even is not necessary. To allocate the code in different flows it would not be desirable, in the first it complicates logic, in the second it would not be desirable to anchor the code to windows and gui generally. A C> the Question - whether it is possible in Qt to organize the cycle of messages and how it to make? QEventLoop?, but I would do easier, created QThread and moved there object, or through QtConcurrent:: run.

4

Re: The cycle of messages in a separate flow

Hello, SaZ, you wrote: SaZ> What for the own? Create separate QThread, then move to it the QObject which works with library. That will do. SaZ> look here at this example. I approximately and do. The library which needs in event loop' is Qt-shnyj QNetworkRequest Look an official example network/http. There a certain GET-inquiry, and all is launched... QNetworkRequest request; request.setUrl (url); reply = qnam.get (request);//we address with GET-inquiry to the server connect (reply, SIGNAL (finished(), this, SLOT (httpFinished ()));//this slot will be caused when with  all will be obtained given vent further from function. When it works in class QWidget or QDialog that all is good, we fall out in an operation cycle of messages , and from this cycle Qt causes slots connected to signals. But I launch it in a separate flow in certain MyWorker:: run () how in your example under the link, and what I should do? To quit from run () to complete a flow and and  the server answer? And the flow is necessary, because there after answer obtaining there should be the durable actions which should not brake GUI. That is me it is necessary or means to wait operation completions qnam.get () in the same flow (i.e. a locking call qnam.get ()), or to get any operation cycle of messages in this flow and to do all in it. And here is how to make it correctly I and do not know.

5

Re: The cycle of messages in a separate flow

Hello, coder9999, you wrote:> also what I should do a C? On termination of operation  to give birth any endOfWork () to a signal which tells to the main GUI-shnomu to a flow that the data is processed also them it is possible to take away.

6

Re: The cycle of messages in a separate flow

Hello, XOOIOOX, you wrote: XOO> On termination of operation  to give birth any endOfWork () to a signal which tells to the main GUI-shnomu to a flow that the data is processed also them it is possible to take away. No, you do not understand a question. I and do, but that is not the question.  consists of a cycle in which two tasks sequentially are launched. One - reversal to a network with termination waiting in eventloop'; and when the data is received - other task starts them to process. Processed - again reversal to a network and so until then while all data will not be downloaded and processed. All Was possible to force to work it at the expense of creation local QEventLoop. But the new problem came to light - in this construction for some reason does not work QTimer. The elementary thing working everywhere and always - we declare object of the timer, we connect a signal timeout to the slot, we launch the timer, through specified time control comes to the slot. And that it is is less specific here does not work. However it is necessary - for handling  http connections.

7

Re: The cycle of messages in a separate flow

8

Re: The cycle of messages in a separate flow

Hello, coder9999, you wrote: a C> Hello, SaZ, you wrote: SaZ>> What for the own? Create separate QThread, then move to it the QObject which works with library. That will do. SaZ>> look here at this example.> I approximately and do a C. The C> Library which needs in event loop' is Qt-shnyj QNetworkRequest a C>... A C> But I launch it in a separate flow in certain MyWorker:: run () how in your example under the link, and what I should do? To quit from run () to complete a flow and and  the server answer? It is not necessary to redefine QThread:: run, it is enough  to make moveToThread and to cause it through slots. The C> And a flow is necessary, because there after answer obtaining there should be the durable actions which should not brake GUI. A C> That is me it is necessary or means to wait operation completions qnam.get () in the same flow (i.e. Locking call qnam.get ()) or to get any operation cycle of messages in this flow and to do all in it. And here is how to make it correctly I and do not know. Implementation QThread:: run already contains a cycle and it launches.