21,480
社区成员
发帖
与我相关
我的任务
分享
class Q_CORE_EXPORT QRunnable
{
int ref;
friend class QThreadPool;
friend class QThreadPoolPrivate;
friend class QThreadPoolThread;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_DISABLE_COPY(QRunnable)
#endif
public:
virtual void run() = 0;
QRunnable() : ref(0) { }
virtual ~QRunnable();
bool autoDelete() const { return ref != -1; }
void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
};
QRunnable不是QObject的子类,所以自身无法使用signal/slot。但是你可以定义其它的辅助类继承QObject来实现。