Unsolved pthread w/ class in QT
-
Hello ! : )
I'm making a qt program which need to be able to run 2 method of 2 differents class at the same time. I already made it run with the method declared in the main() and it works, but i need to make it run with the 2 methods from different classes, with pthread.h . I'm stuck ! Need help , thanks : )
-
Hi
it must be pthreads?
If something very light, u could use a QTimer.
else, this might be helpful
https://computing.llnl.gov/tutorials/pthreads/ -
@mrjj No it mustn't be pthreads but its too heavy to use a Qtimer, any suggestions ? The link you gave does not help me to use pthread with class, unless i have made a bad reading but thanks : )
-
@jackyPITCH said:
pthread
is not based on classes, its a c api.
But nothing wrong calling some class function from the thread.
Since its C it dont accept a class for callback directly.however, Qt has it own thread handling
http://doc.qt.io/qt-5/thread-basics.html
with many examples
http://doc.qt.io/qt-5/examples-threadandconcurrent.htmlSo maybe thats an options?
-
@mrjj i'm using qt4, does this work?
-
@jackyPITCH
hi, i think so
http://doc.qt.io/qt-4.8/threads.htmlalso , should be quick to test out using
https://fabienpn.wordpress.com/2013/05/01/qt-thread-simple-and-stable-with-sources/