Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

QIWidgetValidator Class Reference

List of all members.

Detailed Description

The QIWidgetValidator class is a widget validator. Its purpose is to answer the question: whether all relevant (grand) children of the given widget are valid or not. Relevant children are those widgets which receive some user input that can be checked for validity (i.e. they have a validator() method that returns a pointer to a QValidator instance used to validate widget's input). The QLineEdit class is an example of such a widget.

When a QIWidgetValidator instance is created it receives a pointer to a widget whose children should be checked for validity. The instance connects itself to signals emitted by input widgets when their contents changes, and emits its own signal, validityChanged() (common for all child widgets being observed), whenever the change happens.

Objects that want to know when the validity state changes should connect themselves to the validityChanged() signal and then use the isValid() method to determine whether all children are valid or not.

It is assumed that all children that require validity checks have been already added to the widget when it is passed to the QIWidgetValidator constructor. If other children (that need to be validated) are added later, it's necessary to call the rescan() method to rescan the widget hierarchy again, otherwise the results of validity checks are undefined.

It's also necessary to call the revalidate() method every time the enabled state of the child widget is changed, because QIWidgetValidator skips disabled widgets when it calculates the combined validity state.

This class is useful for example for QWizard dialogs, where a separate instance validates every page of the wizard that has children to validate, and the validityChanged() signal of every instance is connected to some signal of the QWizard subclass, that enables or disables the Next button, depending on the result of the validity check.

Currently, only QLineEdit and QComboBox classes and their successors are recognized by QIWidgetValidator. It uses the QLineEdit::hasAcceptableInput() and QCombobox::validator() methods to determine the validity state o the corresponding widgets (note that the QComboBox widget must be editable, otherwise it will be skipped).

Definition at line 33 of file QIWidgetValidator.h.

Public Slots

void revalidate ()


void isValidRequested (QIWidgetValidator *aValidator)
void validityChanged (const QIWidgetValidator *aValidator)

Public Member Functions

QString caption () const
bool isOtherValid () const
bool isValid () const
QString lastWarning () const
 QIWidgetValidator (const QString &aCaption, QWidget *aWidget, QObject *aParent=0)
 QIWidgetValidator (QWidget *aWidget, QObject *aParent=0)
void rescan ()
void setCaption (const QString &aCaption)
void setLastWarning (const QString &aLastWarning)
void setOtherValid (bool aValid)
QString warningText () const
QWidget * widget () const
 ~QIWidgetValidator ()

Private Slots

void doRevalidate ()

Private Attributes

QString mCaption
Watched mLastInvalid
QString mLastWarning
bool mOtherValid
QList< Watched > mWatched
QWidget * mWidget


struct  Watched

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index