qtguihelper.h 763 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2022 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. #ifndef QTGUIHELPER_H
  4. #define QTGUIHELPER_H
  5. #include <QtGui/QGuiApplication>
  6. QT_BEGIN_NAMESPACE
  7. namespace QtGuiHelper {
  8. class QOverrideCursorGuard
  9. {
  10. public:
  11. Q_DISABLE_COPY_MOVE(QOverrideCursorGuard)
  12. QOverrideCursorGuard() = default;
  13. ~QOverrideCursorGuard() = default;
  14. void restoreOverrideCursor()
  15. {
  16. if (m_guard) {
  17. QGuiApplication::restoreOverrideCursor();
  18. m_guard = false;
  19. }
  20. }
  21. private:
  22. bool m_guard = true;
  23. };
  24. } // namespace QtGuiHelper
  25. QT_END_NAMESPACE
  26. #endif // QTGUIHELPER_H