Unsolved Can signal slot used as new thread?
-
Option 1:
Void read(buffer)// this read data every second
(
displayData(buffer);// display data at QT screen
)// end of functionOption 2:
Void read(buffer)
(
emit signalData(buffer)
)
connect(this,SIGNAL,signalData(buffer),this,SLOT(displayData(buffer));//defined in constructorTherr is no difference in display data. But just want to know which is better in terms of processing.
Any better suggestions.....
Thanks -
Hi and welcome to devnet,
The rule is: do not directly modify GUI elements form a different thread. Use signals and slots to communicate.
-
@Abhishek2509 said in Can signal slot used as new thread?:
connect(this,SIGNAL,signalData(buffer),this,SLOT(displayData(buffer));/
Here the sender is "this" and the receiver is "this" as well, so to me this still doas not respect the rule stated by @SGaist, correct me if i'm wrong.
Also, you are useing old signal/slot syntax : https://wiki.qt.io/New_Signal_Slot_Syntax