#include class ScopedCursor { public: explicit ScopedCursor(QWidget* widget, Qt::CursorShape cursorShape = Qt::WaitCursor, bool processEvents = false) : m_widget(widget), m_processEvents(processEvents) { if (m_widget) { m_savedShape = m_widget->cursor().shape(); if (m_savedShape != cursorShape) { m_widget->setCursor(cursorShape); if (m_processEvents) QApplication::processEvents(); } } } ~ScopedCursor() { restore(); } void restore() { if (m_widget && m_widget->cursor().shape() != m_savedShape) { m_widget->setCursor(m_savedShape); if (m_processEvents) QApplication::processEvents(); } } private: QWidget* m_widget = nullptr; Qt::CursorShape m_savedShape = Qt::ArrowCursor; bool m_processEvents = false; }; static void reproduce(QWidget* w) { const ScopedCursor cursor(w, Qt::WaitCursor, true); QThread::msleep(5000); QMessageBox::critical(w, "1", "wait cursor is correctly not shown while dialog is shown"); QThread::msleep(5000); } int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget w; w.setWindowTitle("Support Ticket 00753818"); w.resize(360, 120); w.show(); QTimer::singleShot(100, [&w]{ reproduce(&w); }); return app.exec(); }