I am not too great a programmer and quite new to QT sorry for my wording.
I have an already created a sensor class in Qt in a different .cpp file from main, whenever i ran my program it ran slow and lagged so my prof suggested making another thread for the class that retrieves values from sensors. I was wondering to move this class into a seperate new thread do i just simply copy and paste everything (functions calls, signals etc..) under the run() function of the new Qthread.
If this is not the procedure some help in basic terms would b开发者_开发知识库e quite beneficial, I dont really understand the QT index information.
Thanks
If you are novice in Qt and especially multi threading, I recommend you to try Qt Concurrent Framework. That will at least protect you form crashes and deadlocks that hard to find out without having enough experience. Use QFuture and QFutureWatcher to execute your function in a thread and read the data.
Overall, your description is very general so I'm not sure its possible to provide a definitive answer how to use your class with QThread.
精彩评论