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. Validators in QML
Forum Updated to NodeBB v4.3 + New Features

Validators in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
13 Posts 3 Posters 2.5k 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.
  • D Offline
    D Offline
    dheerendra
    Qt Champions 2022
    wrote on 2 Nov 2018, 03:34 last edited by
    #2

    You can use conditional operator and define the validators with ids.

    e.g
    IntValidator {id:three;bottom: 11; top: 31;}
    IntValidator {id:four;bottom: 40; top: 50;}
    property int val:1

    validator:val===0?three:four

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Shubham Gupta
      wrote on 2 Nov 2018, 05:29 last edited by
      #3

      I used conditional operator like this:

      validator: val===0?RegExpValidator:DoubleValidator

      But it is showing an error.

      Shubham Gupta

      J 1 Reply Last reply 2 Nov 2018, 05:38
      0
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 2 Nov 2018, 05:35 last edited by
        #4

        show me what are these RegExpValidator:DoubleValidator ?

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        S 1 Reply Last reply 2 Nov 2018, 06:05
        0
        • S Shubham Gupta
          2 Nov 2018, 05:29

          I used conditional operator like this:

          validator: val===0?RegExpValidator:DoubleValidator

          But it is showing an error.

          J Online
          J Online
          J.Hilk
          Moderators
          wrote on 2 Nov 2018, 05:38 last edited by J.Hilk 11 Feb 2018, 05:39
          #5

          @Shubham-Gupta
          you'll have to read up on the Conditional Operator

          It reqiuers 2 expression after the ? your examply only has 1

          forget everything, it's to damn early in the morning.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Shubham Gupta
            wrote on 2 Nov 2018, 05:51 last edited by
            #6

            What?
            I din get your words.

            Shubham Gupta

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dheerendra
              Qt Champions 2022
              wrote on 2 Nov 2018, 06:05 last edited by
              #7

              Please paste your code here. You need to use ternary operator. You may be doing in some mistake. Hence requested paste the code.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              0
              • D dheerendra
                2 Nov 2018, 05:35

                show me what are these RegExpValidator:DoubleValidator ?

                S Offline
                S Offline
                Shubham Gupta
                wrote on 2 Nov 2018, 06:05 last edited by
                #8

                @dheerendra

                validator: val===0?DoubleValidator{
                                top: top_value
                                bottom:bottom_value}
                             : RegExpValidator{regExp: ""}
                

                I am trying to make regular exp for accepting time(mm:ss).
                But its showing an error.

                Shubham Gupta

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on 2 Nov 2018, 06:06 last edited by
                  #9

                  what is the error ?

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Shubham Gupta
                    wrote on 2 Nov 2018, 06:20 last edited by
                    #10

                    @dheerendra

                    Hi dheerendra
                    In qml there are three validators

                    1. IntValidator
                    2. DoubleValidator
                    3. RegExpValidator

                    If i want to store text like 2:30 (mm:ss). So which validator will work.
                    If RegExpValidor is used, so what will be the regular expression for this syntax (mm:ss).

                    Shubham Gupta

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dheerendra
                      Qt Champions 2022
                      wrote on 2 Nov 2018, 07:12 last edited by
                      #11

                      Use RegExpValidator. Did you check the google for regular expression for mm:ss ? It should help.

                      Dheerendra
                      @Community Service
                      Certified Qt Specialist
                      http://www.pthinks.com

                      S 1 Reply Last reply 13 Nov 2018, 06:37
                      0
                      • D dheerendra
                        2 Nov 2018, 07:12

                        Use RegExpValidator. Did you check the google for regular expression for mm:ss ? It should help.

                        S Offline
                        S Offline
                        Shubham Gupta
                        wrote on 13 Nov 2018, 06:37 last edited by
                        #12

                        @dheerendra

                        solved.
                        thanks

                        Shubham Gupta

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          dheerendra
                          Qt Champions 2022
                          wrote on 13 Nov 2018, 06:46 last edited by
                          #13

                          Good. Move the case to "Solved" state. It helps others as well.

                          Dheerendra
                          @Community Service
                          Certified Qt Specialist
                          http://www.pthinks.com

                          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