RunnableThread.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef RUNNABLETHREAD_H
  2. #define RUNNABLETHREAD_H
  3. #ifndef CUSTOMRUNNABLE_H
  4. #define CUSTOMRUNNABLE_H
  5. #include <QRunnable>
  6. #include <QScopedPointer>
  7. class CustomRunnablePrivate;
  8. class CustomRunnable : public QRunnable
  9. {
  10. Q_DISABLE_COPY(CustomRunnable)
  11. public:
  12. CustomRunnable();
  13. ~CustomRunnable();
  14. void setCallbackFunction(void (*callback)(void *), void *parameter);
  15. protected:
  16. void run();
  17. private:
  18. friend class CustomRunnablePrivate;
  19. QScopedPointer<CustomRunnablePrivate> m_Private;
  20. };
  21. #endif // CUSTOMRUNNABLE_H
  22. #ifndef CUSTOMTHREAD_H
  23. #define CUSTOMTHREAD_H
  24. #include <QThread>
  25. #include <QScopedPointer>
  26. class CustomThreadPrivate;
  27. class CustomThread : public QThread
  28. {
  29. Q_DISABLE_COPY(CustomThread)
  30. public:
  31. explicit CustomThread(QObject *parent = NULL);
  32. ~CustomThread();
  33. void setCallbackFunction(void (*callback)(void *), void *parameter);
  34. void setEventLoop(const bool exec);
  35. void setusleep(const unsigned long value);
  36. public slots:
  37. void callbackFunctionSlots();
  38. protected:
  39. void run();
  40. private:
  41. friend class CustomThreadPrivate;
  42. QScopedPointer<CustomThreadPrivate> m_Private;
  43. };
  44. #endif // CUSTOMTHREAD_H
  45. #endif // RUNNABLETHREAD_H