Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Regular expressions

Regular expressions

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 455 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    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:

    enabled:
    {
       var regX = /[.]/g;
       if(entryDisplay.text.search(regX) === -1)
       {
           true
       }
       else
       {
          false
       }
    }
    

    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.

    ODБOïO 1 Reply Last reply
    0
    • C Circuits

      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:

      enabled:
      {
         var regX = /[.]/g;
         if(entryDisplay.text.search(regX) === -1)
         {
             true
         }
         else
         {
            false
         }
      }
      

      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.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      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
      
      C 1 Reply Last reply
      3
      • ODБOïO ODБOï

        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
        
        C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved