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

QWidget::move() does not work well in Linux X11

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • None
    • 6.2.0 Beta1
    • None
    • Fedora 34, newest Xfce, GCC 11
    • Linux/X11

    Description

      I am developing a music player. For the sake of beauty, I designed a customized QFrame as title bar, and wrote the following popular codes to add the dragging function.

      void
      TP_TitleBar::mousePressEvent(QMouseEvent *event)
      {
          if(event->button() == Qt::LeftButton)
          {
              isBeingPressed = true;
              pressedPosition = event->globalPosition().toPoint();
          }
          QWidget::mousePressEvent(event);
      }
      
      void
      TP_TitleBar::mouseMoveEvent(QMouseEvent *event)
      {
          if(isBeingPressed)
          {
              QPoint movePoint = event->globalPosition().toPoint() - pressedPosition;
              pressedPosition = event->globalPosition().toPoint();
              window()->move(window()->pos() + movePoint);
          }
          QWidget::mouseMoveEvent(event);
      }
      
      void
      TP_TitleBar::mouseReleaseEvent(QMouseEvent *event)
      {
          isBeingPressed = false;
          QWidget::mouseReleaseEvent(event);
      }
      

      These code works like a charm in Windows.

      However in Linux, the code works, but not so well. The mouse cursor does not follow well the widget point where the user clicked.

      Considering the fact that all popular desktop environments under Linux do not have this problem since we can drag all windows fluently, it means that the Qt implementation of this part may need to be improved.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            zxfksie Xiang Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes