Important: Please read the Qt Code of Conduct -

Set RegExpValidator to qml object

  • Hi,
    i am very new to qml.

    i try to set a regExpValidator to a qml object defined in another file.

    It does not work :(

    If i directly set the regExp in File 3 it works...

    Maybe somebody knows what the problem is?

    For exmaple:

    File 1 (here i want to define all reg expressions)

    property string test_reg_exp_1: /[0-9A-Z]+/
    property string test_reg_exp_2: /[a-z]+/@

    File 2: (this should be a generic qml object where i want to set the RegExpValidator from File 3)

    @Rectangle {
    id: dialogTextEdit

    property string validatorStr
    TextInput {

    validator: RegExpValidator { regExp: validatorStr }



    File 3:

    @DialogTextEdit {
    id: dataField_1
    validatorStr: file1.test_reg_exp_1
    DialogTextEdit {
    id: dataField_2
    validatorStr: file1.test_reg_exp_2


Log in to reply