-
Notifications
You must be signed in to change notification settings - Fork 58
IntInputValidator rejects partial input, making some fields uneditable #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+44
−9
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: musescore/muse_framework
Length of output: 50380
🏁 Script executed:
Repository: musescore/muse_framework
Length of output: 35987
🏁 Script executed:
Repository: musescore/muse_framework
Length of output: 9459
🌐 Web query:
site:doc.qt.io/qt-6 QML TextInput validator fixup editingFinished Intermediate💡 Result:
In QML's TextInput, the interaction between validators, the fixup method, and signals like editingFinished is defined by the underlying QValidator and input handling architecture [1][2][3]. Validators and States When a validator (such as IntValidator or RegularExpressionValidator) is applied to a TextInput, it categorizes input into three states: Acceptable, Intermediate, and Invalid [2][4]. 1. Acceptable: The text meets all requirements for final submission [2]. 2. Intermediate: The text is incomplete or currently invalid but could become valid with further editing [2][4]. 3. Invalid: The text violates the validator's rules [2]. Behavior of editingFinished and accepted The editingFinished and accepted signals in TextInput are subject to validation checks [1][5]. If a validator or inputMask is set, these signals are emitted only if the current text is in an Acceptable state [1][3]. If the user attempts to finish editing (e.g., by pressing Enter or losing focus) while the input is in an Intermediate or Invalid state, the signal will not be emitted [1][3]. Role of fixup The fixup method is a virtual function provided by the QValidator class [2]. Its purpose is to attempt to automatically repair Invalid text when the user finishes editing [2]. For example, a validator could implement fixup to pad a number or remove forbidden characters [2]. Crucially, in QML TextInput: - The TextInput component does not automatically trigger fixup in the same way certain legacy QWidget components (like QLineEdit or QAbstractSpinBox) might implicitly do during specific user actions [2][3][6]. - If you require auto-correction of user input, you must manually trigger the logic—typically by handling the editingFinished or lost focus events—to validate the text and manually invoke a fixup-like function or transformation on the text property [2]. - Because fixup is a C++-level mechanism, developers using QML who need complex validation behavior often implement their validation and "fixup" logic directly in QML by responding to changes in the text property or by handling the signals manually [7]. Summary for Developers If you are seeing scenarios where input is not being accepted or signals are not firing, it is because the input remains in an Intermediate state [7][4]. To ensure a consistent user experience: - Use the acceptableInput property to provide immediate visual feedback (e.g., changing text color) so users know why their input might not be "finishing" [7]. - Do not rely on automatic fixup behavior in QML; instead, implement explicit input sanitization in your QML handlers when the user finishes editing [2].
Citations:
🌐 Web query:
site:doc.qt.io/qt-6/qml-qtquick-textinput.html "editingFinished" "acceptable"💡 Result:
The term editingFinished typically refers to a signal in software frameworks, most notably in the Qt framework, which notifies the application that a user has finalized their input in a text field [1]. In the context of Qt's TextInput and related components, editingFinished is emitted under two primary conditions: when the user presses the Return or Enter key, or when the text input loses focus [1]. Regarding the condition of it being acceptable, documentation specifies that if a validator or inputMask is applied to the text input, the editingFinished signal will only be emitted if the input meets the requirements of the inputMask and the validator returns an acceptable state [1]. Therefore, in environments utilizing such validation, the signal serves as a gatekeeper to ensure that only valid or acceptable data is processed after the editing session concludes [1].
Citations:
Handle
Intermediateinput before commitTextInputFieldforwardsTextField.onEditingFinisheddirectly, but Qt emits that signal only when the validator returnsAcceptable.IntInputValidatorreturnsIntermediatefor empty, sign-only, and out-of-range values, and QML does not invokeQValidator::fixup()automatically. Add an explicit focus-loss or accept path that clamps the value before emittingvalueEditingFinished.🤖 Prompt for AI Agents