RegularExpressionValidator QML Type
Fornisce un validatore di stringhe. Maggiori informazioni...
| Import Statement: | import QtQuick |
| In C++: | QRegularExpressionValidator |
Proprietà
- regularExpression : regularExpression
Descrizione dettagliata
Il tipo RegularExpressionValidator fornisce un validatore che considera valida qualsiasi stringa che corrisponda a un'espressione regolare specificata.
Vedi anche IntValidator, DoubleValidator e Validazione del testo immesso.
Documentazione delle proprietà
regularExpression : regularExpression
Questa proprietà contiene l'espressione regolare utilizzata per la convalida.
Si noti che questa proprietà deve essere un'espressione regolare nella sintassi JS, ad esempio /a/ per l'espressione regolare che corrisponde a "a".
Per impostazione predefinita, questa proprietà contiene un'espressione regolare con il modello .* che corrisponde a qualsiasi stringa.
Di seguito è riportato un esempio di oggetto ` TextInput ` con specificata l'espressione regolare ` RegularExpressionValidator `:
TextInput {
id: hexNumber
validator: RegularExpressionValidator { regularExpression: /[0-9A-F]+/ }
}Alcuni altri esempi di espressioni regolari:
- Un elenco di numeri con da una a tre cifre separati da una virgola:
/\d{1,3}(?:,\d{1,3})+$/ - Un importo composto da un massimo di 3 cifre prima della virgola decimale e da 1 a 2 cifre dopo la virgola decimale:
/(\d{1,3})([.,]\d{1,2})?$/
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.