I have a class QUdpSocket which reads data packets from the socket and emits them to another object other than MainWindow. I initialize the construction of this QUdpSocket inside MainWindow and connect its signals.

Today I noticed reading packets from the socket makes ui interaction slow. I think this is because the socket object is defined inside MainWindow implementation and is one of the tasks of MainWindow which takes CPU cycle to itself and releases. To remedy this problem, I thought of defining a QThread and run this thread inside MainWindow.
I believe running the QThread inside MainWindow would not slow down the UI anymore, as the Thread executes kinda like the way a child process initiates and departs from its parent. I hope what I thought of so far is correct.

Next, I have one ambiguity about the inner implementation of QThread Socket. I need to initialize the port and connect the signals in the constructor of course. For the main task which is reading buffer when they become available on the socket, should the main code like "if there is a packet then read, otherwise continue" be implemented in the thread run function? is yes, is it called in regularly in a loop? or it will only execute when the readyRead() signal is triggered?

I would thank if someone could explain this to me with a code template.

Cheers,