Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
mouseQuickSelectionThreshold isn't set to the correct default value on Windows
david_fmod last edited by
In Qt 5.11, the mouseQuickSelectionThreshold style hint was added; see https://eang.it/new-in-qt-5-11-quick-text-selection-in-qlineedit/ and https://codereview.qt-project.org/c/qt/qtbase/+/192811.
The default value for this style hint is 10: https://github.com/qt/qtbase/blob/dev/src/gui/kernel/qplatformtheme.cpp#L565
The Windows platform integration doesn't override this value: https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsintegration.cpp#L585
This results in QLineEdit widgets not behaving like normal Windows text boxes, which ignore all vertical cursor movement when determining selection. Instead the QLineEdit widgets are defaulting to the MacOS-like behaviour that was added in the changes above. The default value should be -1 on Windows, to disable the quick-selection behaviour entirely - this seems to be an oversight and a bug.
I've tried setting the threshold value in the object returned from QGuiApplication::styleHints, but I've not noticed any change from doing so, and the documentation indicates that the QStyleHints object is read-only (despite having setter functions). Also note that the setMouseQuickSelectionThreshold is marked as internal and thus doesn't appear in the documentation.
Is there a way I can override this threshold value to -1 to disable this behaviour globally in our application?
Modify the Qt source code and (even better) provide a patch to read the value from windows settings.