In Qt Application code Class A
has one member method like method1()
. I want to call this method in another member function method2()
and run mehtod1()
in a different thread. But what I found from the qt documentation is follows.
- Inherit a new
class MyThread
(suppose) fromQThread
. - Override the function method
run()
with your required code. - Create an object of
MyThread
inClass A
and then call the run function wherever you want.
But the above seems bit complex. Is there any mechanism in Qt so that I can create a new QThread
(without inheriting) instantly in my method1()
and run the method2()
with this thread and then return to method1()
after execution finishes?
Please let me know if I am not clear in my question.