Details
-
Bug
-
Resolution: Done
-
P4: Low
-
None
-
6.2.0 Beta1
-
None
-
Fedora 34, newest Xfce, GCC 11
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.