Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.2
-
None
-
The test program was built with a MinGw 10.3.0 environment
Description
If the main window of an application loses focus in Windows while a QSlider is dragged, the slider stays in 'pressed' state after mouse release: Slider returns 'true' on calling function isSliderDown and is also drawn the corresponding way.
Beside the wrong slider style this leads to the following errors (which might accidentally change application settings as well):
1. If slider is in corrupt state and the underlying main window is moved on screen, sometimes the slider jumps to another position when window dragging is stopped.
2. If a special style sheet is set for the slider (special style for hovering), the slider (in corrupt state) automatically updates to mouse position whenever the mouse hovers application between slider start and end coordinate (without being pressed). - The application is unusable now as long until slider is reset.
1. may be reproduced the following way:
- Build the Qt sliders example (examples/widgets/widgets/sliders/sliders.pro).
- Open Qt sliders example
- Drag the slider (which is shown on right top) to the right -
- Keep mouse button pressed while pessing key combination 'Windows-Key' + 'M' (for minimizing all windows to task bar) - release mouse button again afterwards
- Show slider example dialog again by selecting application icon in the taskbar
- Now the slider state is always pressed (drawn grey)
- Move the dialog by dragging its frame - on drag stop, the slider jumps to the left
2. may be reproduced the following way:
- Open the Qt sliders example (examples/widgets/widgets/sliders/sliders.pro).
- Add the following line to the SlidersGroup constructor: slider->setStyleSheet("QSlider::handle:hover {background-color: red};}");
- Build and open the application
- Drag slider -
- Keep mouse button pressed while pessing key combination 'Windows-Key' + 'M' (for minimizing all windows to task bar) - release mouse button again afterwards
- Show slider example dialog again by selecting application icon in the taskbar
- Now the slider state is always pressed (drawn grey)
- Whenever mouse hovers the application in region above and below the slider (without being pressed), the slider is moved to the actual horizontal mouse position
In real life these bugs may e.g. occur if a message dialog (of the Qt application itself or of any other application that is run on a PC) comes up while user is dragging the slider. After that the slider is in corrupt state (and sometimes sends wrong values to the application as described above) until it is pressed and correctly released once again. Note that this is a really bad bug if slider is connected to any important machine controls.
Idea how to solve this problem: Add a check to QSlider's leaveEvent implementation that checks whether isSliderDown returns true - if yes, act as if dragging was stopped (reset slider to state like in implementation of mouseReleaseEvent).