Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setCursor() stops working after interacting with QMessageBox using space key
QtWS25 Last Chance

setCursor() stops working after interacting with QMessageBox using space key

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 372 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Hoang
    wrote on 20 Mar 2025, 07:10 last edited by
    #1

    Hi everyone,

    I am experiencing an issue where setCursor() stops working after interacting with a QMessageBox using the space key.

    System Information:
    • Qt Version: 6.8.2
    • OS: macOS Sequoia 15.3.2
    • Compiler: Apple clang version 16.0.0 (clang-1600.0.26.6)
    Problem Description:

    In my QGraphicsView-based application, I use setCursor() to change the cursor based on user interactions. Everything works fine until I open a QMessageBox.

    • Everything works correctly if I click the message box buttons with the mouse.
    • However, if I use the space key to interact with the message box, setCursor() stops working.
    • Even after clicking on the graphics view again, changing the cursor programmatically no longer has any effect.
    • The cursor only resets to the expected behavior if I move or resize the application window.
    What I Have Tried:
    • Using setCursor() and viewport()->setCursor() on QGraphicsView.
    • Calling update(), repaint(), and viewport()->update() after setting the cursor.
    • Forcing a cursor reset using unsetCursor() before setCursor().
    • Setting the cursor on QApplication instead of QGraphicsView.
    • Ensuring that focus is correctly set back to QGraphicsView after closing the QMessageBox.

    None of these solutions have worked.

    Question:
    • Has anyone encountered this issue before?
    • Is there a workaround to force setCursor() to work again after interacting with a QMessageBox via the space key?

    Any help or suggestions would be greatly appreciated!
    Thanks!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Mar 2025, 20:37 last edited by SGaist
      #2

      Hi and welcome to devnet,

      Are you using exec or open ?
      If the former, can you test with the latter ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kevin Hoang
        wrote on 21 Mar 2025, 02:03 last edited by
        #3

        I am using confirmBox.exec() because I want the user to confirm before proceeding. The blocking behavior is intentional in this case.

        However, I am also facing another issue with QGraphicsRectItem:

        After zooming in or out, the hover event does not work in a ~10px area at the bottom edge of the RectItem. Additionally, setCursor does not take effect until I move the application window.

        I suspect these issues might be related, but I don’t think they are caused by exec(). Do you have any insights on what might be happening?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 21 Mar 2025, 13:47 last edited by
          #4

          wrt to the QGraphicsrectItem - any chance you hit bug https://bugreports.qt.io/browse/QTBUG-131893 ?
          Please provide a minimal, compilable example to reproduce the problem.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kevin Hoang
            wrote on 22 Mar 2025, 05:22 last edited by
            #5

            I've provided a minimal, compilable example to reproduce the issue. You can find it here:
            👉 GitHub Repository: QGraphicsBug

            The repository includes build instructions and a detailed Steps to Reproduce section in the README.

            Would appreciate any insights or suggestions. Thanks!

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kevin Hoang
              wrote on 22 Mar 2025, 06:55 last edited by
              #6

              I've noticed something interesting: If an action automatically triggers a QMessageBox, and I press Space to interact with it, the issue occurs. However, if I repeat the same action one more time, setCursor() starts working again.

              This suggests that Qt's internal state might not be resetting correctly after the first QMessageBox interaction, but it somehow corrects itself on the second occurrence.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 23 Mar 2025, 18:27 last edited by
                #7

                I can't reproduce it with Qt6.8.2 or Qt6.10 on windows with msvc.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kevin Hoang
                  wrote on 24 Mar 2025, 03:48 last edited by
                  #8

                  Thanks for testing it!

                  I'm running this on macOS Sequoia 15.3.2 with Qt 6.8.2, using Apple Clang 16.0.0. The issue is consistently reproducible on my setup. This might be a macOS-specific issue.

                  Would it make sense to report this on Qt's bug tracker (bugreports.qt.io)?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 25 Mar 2025, 12:21 last edited by
                    #9

                    Yes it would, I was able to reproduce the issue on Sonoma with a self built version of Qt.

                    Please provide your example directly in the bug report so it will keep things together.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kevin Hoang
                      wrote on 25 Mar 2025, 17:45 last edited by
                      #10

                      I really appreciate you taking the time to look into this issue!

                      I have submitted the bug report to Qt's bug tracker and included the minimal example directly in the report. Here is the link for reference: QTBUG-135154

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 25 Mar 2025, 19:52 last edited by
                        #11

                        Thanks !

                        Please add a tar file with your project to the report. That way it's easier for people to work on this.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        1/11

                        20 Mar 2025, 07:10

                        • Login

                        • Login or register to search.
                        1 out of 11
                        • First post
                          1/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved