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. Is there an "aggregate" version of QValidator?
Qt 6.11 is out! See what's new in the release blog

Is there an "aggregate" version of QValidator?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.9k Views 2 Watching
  • 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.
  • NathanielN Offline
    NathanielN Offline
    Nathaniel
    wrote last edited by
    #1

    I'm thinking of something vaguely analogous to QButtonGroup, which aggregates logically related (not necessarily spatially proximate) QButtons and provides global features like exclusiveness and id's. Suppose I have a collection of input-like controls (check boxes, radio button, QLineEdit, spinners and such) and I want to run code to validate the whole collection, which might have mutual dependencies. I realize I could just use multiple separate QValidators and/or implement some validate() method, but I'd like to know if there is a (maybe 3rd party) library which covers these cases in a systematic way. Something like a "QValidatorGroup" base class that could be subclassed with a concrete validate() implementation and have its own signals, slots, and properties as appropriate? That seems more efficient than recreating the relevant functionally ad-hoc for each QDialog or QMainWindow which has some notion of aggregate validation.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      I am not aware of such a control but you description made me think of QWizardPage.
      You register your fields, if all mandatory fields have been field, the isComplete function will return true so QWizard can enabled/disable the next/finish buttons based on that.

      It sounds like you want something a bit similar.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SimonSchroeder
        wrote last edited by
        #3

        The idea of the QValidator is to validate while you are typing/changing the value. If you just want to validate at the end (not while things are changed), then you can just write a function that goes over all the widgets.

        I remember a talk by an Adobe employee that was about something similar. AI tells me the speaker is Sean Parent and the library is Adam (a.k.a the Property Model Library or PML) which is part of the Adobe Source Libraries (ASL). Maybe you can find it and adapt some of their ideas. It is not explicitly written for Qt and might not work with it out of the box.

        1 Reply Last reply
        1
        • S Offline
          S Offline
          sales99
          wrote last edited by
          #4

          you can put a QMap of validators/input widgets and signal every input change to slot that checks the inputs for validity. you could sub-class all items to emit a same signal to indicate input change, that would allow to put them in some validity checker. or if the ::event stuff allows it better

          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