0
votes

So apparently when we are multi-threading in pyqt by using QThread, we will have to subclass QThread and it can not be directly instantiated. this implies that QThread is an abstract class.

That's fine, but the thing that i don't understand is that when we are subclassing QThread, we only override the run() method, but in order to actually get this multi-threading feature to work, we have to call the start() method of the QThread subclass which we did not override at all (AFAIK if we are subclassing an abstract class, we will have to override every method that it has in our child class otherwise it can not b instantiated).

So where does the start() and finish methods come from?

1

1 Answers

3
votes

Not every method of an abstract class is itself abstract. In the case of a QThread, the methods start() and finish() will have the same behavior across all subclasses, so they have concrete implementations for you to use, but there is no base implementation of run() (since that defines what the thread does) so that is abstract and requires custom implementation.