Important: Please read the Qt Code of Conduct -

Regular expressions

  • I am trying to search this string for a " . " and if it is not found I want this button to be enabled. Something like this:

       var regX = /[.]/g;
       if( === -1)

    but I can't seem to figure out how to declare this regular expression in QML. The documentation is confusing me I dont see why I would need to use QRegExpValidator class for this and even if I do, for some reason, even though I have imported QtQuick I can't create a QRegExp variable.

  • hi
    you forgot return

    **return** true 

    you can also use indexOf(str) js function, it returns -1 if str is not found

     enabled: entryDisplayText.indexOf(".")=== -1

  • @LeLev Ah I see now, thank you. Yes the other way you mentioned is more simple, I think I will use that, thanks.

Log in to reply