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

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

XMLWordPrintable

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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes