Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-133541

QApplication::restoreOverrideCursor restores wrong cursor on Wayland

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.9
    • QPA: Wayland
    • None
    • Fedora 41, KDE Plasma
    • Linux/Wayland

    Description

      Consider the following code:

      #include <QApplication>
      #include <QMainWindow>
      #include <QPushButton>
      #include <QLayout>
      
      int main(int argc, char**argv) {
          QApplication app(argc, argv);
      
          auto window1 = new QMainWindow;
          window1->setCursor(QCursor(Qt::OpenHandCursor));
          auto window2 = new QMainWindow;
          window2->setCursor(QCursor(Qt::PointingHandCursor));
      
          auto button = new QPushButton(window2);
          button->setText("Do override");
          button->setCheckable(true);
          window2->layout()->addWidget(button);
      
          QObject::connect(button, &QPushButton::toggled, window1, [](bool checked){
              if (checked) {
                  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
              } else {
                  QApplication::restoreOverrideCursor();
              }
          });
          window1->show();
          window2->show();
      
          return app.exec();
      } 

      The two windows have a different cursor, the one with the button has a pointing cursor whereas the empty one has an open hand cursor.

      Clicking the button sets an override cursor, and clicking it again restores the original cursor.

      On Wayland that does not work correctly, now the window with the button has the cursor from the other window. Only after some interaction (e.g. leaving and re-entering the window) the right cursor returns.

      It works as expected with xcb

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            davidedmundson David Edmundson
            nicolasfella Nicolas Fella
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes