Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do i Create a Custom Validator?
Forum Updated to NodeBB v4.3 + New Features

How do i Create a Custom Validator?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • N Offline
    N Offline
    nullbuil7
    wrote on last edited by
    #1

    hi i want to create an int validator that only allows 0 - 255 numbers. but i don't know the syntax of creating a custom int validator.

    JonBJ 1 Reply Last reply
    0
    • N nullbuil7

      hi i want to create an int validator that only allows 0 - 255 numbers. but i don't know the syntax of creating a custom int validator.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @nullbuil7
      Use a QIntValidator! I know you don't like this from your other thread. I suppose you could derive from QIntValidator and override validate() to return Invalid instead of Intermediate if the third digit puts it over 255. You'd have to try it out and see how it behaves.

      But why aren't you using a QSpinBox for your widget, that has a minimum and a maximum, it's a dedicated widget for what you want? You seem to want to reinvent the wheel in your situation?

      1 Reply Last reply
      2
      • N Offline
        N Offline
        nullbuil7
        wrote on last edited by
        #3

        I'm sorry I'm just new at this and i was don't know enough qt and c++ yet. sorry for spamming I'll try QSpinBox

        JonBJ 1 Reply Last reply
        0
        • N nullbuil7

          I'm sorry I'm just new at this and i was don't know enough qt and c++ yet. sorry for spamming I'll try QSpinBox

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @nullbuil7
          If the spin box does not suit you, I have edited to suggest above how you might subclass QIntValidator to alter the default 3-digit behaviour to what I think you are looking for.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nullbuil7
            wrote on last edited by
            #5

            how do i get around this?

            https://forum.qt.io/topic/108103/cant-find-qlocaledata

            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