Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Q3DateEdit Class Reference
[Qt3Support module]

The Q3DateEdit class provides a date editor. More...

 #include <Q3DateEdit>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits Q3DateTimeEditBase.

Public Types

  • enum Order { MDY, DMY, YMD }

Properties

  • 56 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

  • 201 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Public Slots

  • virtual void setDate ( const QDate & date )
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Protected Functions

  • 38 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Protected Slots

  • 1 protected slot inherited from QWidget

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject

Detailed Description

The Q3DateEdit class provides a date editor.

Q3DateEdit allows the user to edit dates by using the keyboard or the arrow keys to increase/decrease date values. The arrow keys can be used to move from section to section within the Q3DateEdit box. Dates appear in accordance with the local date/time settings or in year, month, day order if the system doesn't provide this information. It is recommended that the Q3DateEdit be initialised with a date, e.g.

 Q3DateEdit *dateEdit = new Q3DateEdit(QDate::currentDate(), this);
 dateEdit->setRange(QDate::currentDate().addDays(-365),
                     QDate::currentDate().addDays( 365));
 dateEdit->setOrder(Q3DateEdit::MDY);
 dateEdit->setAutoAdvance(true);

Here we've created a new Q3DateEdit object initialised with today's date and restricted the valid date range to today plus or minus 365 days. We've set the order to month, day, year. If the auto advance property is true (as we've set it here) when the user completes a section of the date, e.g. enters two digits for the month, they are automatically taken to the next section.

The maximum and minimum values for a date value in the date editor default to the maximum and minimum values for a QDate. You can change this by calling setMinValue(), setMaxValue() or setRange().

Terminology: A Q3DateEdit widget comprises three 'sections', one each for the year, month and day. You can change the separator character using Q3DateTimeEditor::setSeparator(), by default the separator will be taken from the systems settings. If that is not possible, it defaults to "-".

Date Time Widgets

See also QDate, Q3TimeEdit, and Q3DateTimeEdit.


Member Type Documentation

enum Q3DateEdit::Order

This enum defines the order in which the sections that comprise a date appear.

ConstantValueDescription
Q3DateEdit::MDY1month-day-year
Q3DateEdit::DMY0day-month-year
Q3DateEdit::YMD2year-month-day (the default)


Property Documentation

autoAdvance : bool

This property holds whether the editor automatically advances to the next section.

If autoAdvance is true, the editor will automatically advance focus to the next date section if a user has completed a section. The default is false.

Access functions:

  • bool autoAdvance () const
  • virtual void setAutoAdvance ( bool advance )

date : QDate

This property holds the editor's date value.

If the date property is not valid, the editor displays all zeroes and Q3DateEdit::date() will return an invalid date. It is strongly recommended that the editor is given a default date value (e.g. currentDate()). That way, attempts to set the date property to an invalid date will fail.

When changing the date property, if the date is less than minValue(), or is greater than maxValue(), nothing happens.

Access functions:

  • QDate date () const
  • virtual void setDate ( const QDate & date )

maxValue : QDate

This property holds the editor's maximum value.

Setting the maximum date value for the editor is equivalent to calling Q3DateEdit::setRange(minValue(), d), where d is the maximum date. The default maximum date is 8000-12-31.

Access functions:

  • QDate maxValue () const
  • virtual void setMaxValue ( const QDate & d )

See also minValue and setRange().

minValue : QDate

This property holds the editor's minimum value.

Setting the minimum date value is equivalent to calling Q3DateEdit::setRange(d, maxValue()), where d is the minimum date. The default minimum date is 1752-09-14.

Access functions:

  • QDate minValue () const
  • virtual void setMinValue ( const QDate & d )

See also maxValue and setRange().

order : Order

This property holds the order in which the year, month and day appear.

The default order is locale dependent.

Access functions:

  • Order order () const
  • virtual void setOrder ( Order order )

See also Order.


Member Function Documentation

Q3DateEdit::Q3DateEdit ( QWidget * parent = 0, const char * name = 0 )

Constructs an empty date editor which is a child of parent and called name name.

Q3DateEdit::Q3DateEdit ( const QDate & date, QWidget * parent = 0, const char * name = 0 )

Constructs a date editor with the initial value date, parent parent and called name.

The date editor is initialized with date.

Q3DateEdit::~Q3DateEdit ()

Destroys the object and frees any allocated resources.

void Q3DateEdit::fix ()   [virtual protected]

Attempts to fix any invalid date entries.

The rules applied are as follows:

  • If the year has four digits it is left unchanged.
  • If the year has two digits, the year will be changed to four digits in the range current year - 70 to current year + 29.
  • If the year has three digits in the range 100..999, the current millennium, i.e. 2000, will be added giving a year in the range 2100..2999.
  • If the day or month is 0 then it will be set to 1 or the minimum valid day/month in the range.

QString Q3DateEdit::sectionFormattedText ( int sec )   [virtual protected]

Returns the formatted number for section sec. This will correspond to either the year, month or day section, depending on the current display order.

See also setOrder().

QString Q3DateEdit::separator () const

Returns the editor's separator.

See also setSeparator().

void Q3DateEdit::setDay ( int day )   [virtual protected]

Sets the day to day, which must be a valid day. The function will ensure that the day set is valid for the month and year.

void Q3DateEdit::setMonth ( int month )   [virtual protected]

Sets the month to month, which must be a valid month, i.e. between 1 and 12.

void Q3DateEdit::setRange ( const QDate & min, const QDate & max )   [virtual]

Sets the valid input range for the editor to be from min to max inclusive. If min is invalid no minimum date will be set. Similarly, if max is invalid no maximum date will be set.

void Q3DateEdit::setSeparator ( const QString & s )   [virtual]

Sets the separator to s. Note that currently only the first character of s is used.

See also separator().

void Q3DateEdit::setYear ( int year )   [virtual protected]

Sets the year to year, which must be a valid year. The range currently supported is from 1752 to 8000.

See also QDate.

void Q3DateEdit::updateButtons ()   [protected slot]

Enables/disables the push buttons according to the min/max date for this widget.

void Q3DateEdit::valueChanged ( const QDate & date )   [signal]

This signal is emitted whenever the editor's value changes. The date parameter is the new value.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 82
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

La création de colonnes dans une ListView en QML

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web