0

I need your help.

There is a class in C++, in which is implemented relatively difficult algorithms. And I also added to it a graphical interface for QML. I registered the class:

qmlRegisterType<Solver>("xyz.lstu", 1, 0, "Solver");

I launch it as:

onClicked: {
    solver.start()
}

When I run the methods of the class, the GUI stops responding and starts responding only after the function is completed. The class object regularly sends it signals about progress and I want to immediately bring them to the GUI. How to run these methods on a separate thread? In Java, I solved such things like this

SwingUtilities.invokeLater(..) 
Alexander V
  • 8,351
  • 4
  • 38
  • 47
  • 1
    If you want us to help you, you must provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – eyllanesc Oct 30 '17 at 18:36
  • Do you run everything in the same thread? – derM - not here for BOT dreams Oct 30 '17 at 18:48
  • Yes. The question is how to divide – Alexey Prinkov Oct 30 '17 at 18:57
  • About the completeness of the code. There is one function for solving unconditional optimization problems, the calculation of which takes several minutes. Does it make sense to bring it? – Alexey Prinkov Oct 30 '17 at 19:00
  • 1
    Not only you did not provide enough of MCVP (do it next time) but you just need to learn multithreading and ways to accomplish starting the task on a worker thread in Qt. There a number of answers like that. I would create special worker object on (not the one that talks to UI, it has to be on UI thread) and do `moveToThread` for it and then use `invokeMethod` to dispatch a call on worker thread from UI. Like that: https://stackoverflow.com/questions/13948337/why-using-qmetaobjectinvokemethod-when-executing-method-from-thread But of course there is many ways to do so. – Alexander V Oct 30 '17 at 19:02
  • 1
    I voted to close the question as a duplicate of many similar ones. If this one question had specifics preventing the author from doing the task then it would make sense to answer. But the author has just to learn multithreading/ Qt and helping him with the answer would be more of education rather than practical advise. – Alexander V Oct 30 '17 at 19:07

0 Answers0