Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

  • Qt 4.8
  • Qt3SupportLight
  • Q3DateEdit

Q3DateEdit Class

TheQ3DateEdit class provides a date editor.More...

Header:#include <Q3DateEdit>
Inherits:Q3DateTimeEditBase

Public Types

enumOrder { MDY, DMY, YMD }

Properties

Public Functions

Q3DateEdit(QWidget * parent = 0, const char * name = 0)
Q3DateEdit(const QDate & date, QWidget * parent = 0, const char * name = 0)
~Q3DateEdit()
boolautoAdvance() const
QDatedate() const
QDatemaxValue() const
QDateminValue() const
Orderorder() const
QStringseparator() const
virtual voidsetAutoAdvance(bool advance)
virtual voidsetMaxValue(const QDate & d)
virtual voidsetMinValue(const QDate & d)
virtual voidsetOrder(Order order)
virtual voidsetRange(const QDate & min, const QDate & max)
virtual voidsetSeparator(const QString & s)

Reimplemented Public Functions

virtual QSizeminimumSizeHint() const
virtual QSizesizeHint() const

Public Slots

virtual voidsetDate(const QDate & date)
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidvalueChanged(const QDate & date)

Protected Functions

virtual voidfix()
virtual voidsetDay(int day)
virtual voidsetMonth(int month)
virtual voidsetYear(int year)

Reimplemented Protected Functions

virtual boolevent(QEvent * e)
virtual voidresizeEvent(QResizeEvent *)
virtual QStringsectionFormattedText(int sec)
virtual voidtimerEvent(QTimerEvent *)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Protected Slots

  • 1 protected slot inherited fromQWidget

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject

Detailed Description

TheQ3DateEdit 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 theQ3DateEdit 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 theQ3DateEdit be initialised with a date, e.g.

Q3DateEdit*dateEdit=newQ3DateEdit(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 newQ3DateEdit 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 aQDate. You can change this by callingsetMinValue(),setMaxValue() orsetRange().

Terminology: AQ3DateEdit 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 alsoQDate,Q3TimeEdit, andQ3DateTimeEdit.

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:

boolautoAdvance() const
virtual voidsetAutoAdvance(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 thanminValue(), or is greater thanmaxValue(), nothing happens.

Access functions:

QDatedate() const
virtual voidsetDate(const QDate & date)

maxValue :QDate

This property holds the editor's maximum value.

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

Access functions:

QDatemaxValue() const
virtual voidsetMaxValue(const QDate & d)

See alsominValue andsetRange().

minValue :QDate

This property holds the editor's minimum value.

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

Access functions:

QDateminValue() const
virtual voidsetMinValue(const QDate & d)

See alsomaxValue andsetRange().

order :Order

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

The default order is locale dependent.

Access functions:

Orderorder() const
virtual voidsetOrder(Order order)

See alsoOrder.

Member Function Documentation

Q3DateEdit::Q3DateEdit(QWidget * parent = 0, constchar * name = 0)

Constructs an empty date editor which is a child ofparent and called namename.

Q3DateEdit::Q3DateEdit(constQDate & date,QWidget * parent = 0, constchar * name = 0)

This is an overloaded function.

Constructs a date editor with the initial valuedate, parentparent and calledname.

The date editor is initialized withdate.

Q3DateEdit::~Q3DateEdit()

Destroys the object and frees any allocated resources.

[virtual protected]bool Q3DateEdit::event(QEvent * e)

Reimplemented fromQObject::event().

[virtual protected]void Q3DateEdit::fix()

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.

[virtual]QSize Q3DateEdit::minimumSizeHint() const

Reimplemented fromQWidget::minimumSizeHint().

[virtual protected]void Q3DateEdit::resizeEvent(QResizeEvent *)

Reimplemented fromQWidget::resizeEvent().

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

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

See alsosetOrder().

QString Q3DateEdit::separator() const

Returns the editor's separator.

See alsosetSeparator().

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

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

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

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

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

Sets the valid input range for the editor to be frommin tomax inclusive. Ifmin is invalid no minimum date will be set. Similarly, ifmax is invalid no maximum date will be set.

[virtual]void Q3DateEdit::setSeparator(constQString & s)

Sets the separator tos. Note that currently only the first character ofs is used.

See alsoseparator().

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

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

See alsoQDate.

[virtual]QSize Q3DateEdit::sizeHint() const

Reimplemented fromQWidget::sizeHint().

[virtual protected]void Q3DateEdit::timerEvent(QTimerEvent *)

Reimplemented fromQObject::timerEvent().

[protected slot]void Q3DateEdit::updateButtons()

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

[signal]void Q3DateEdit::valueChanged(constQDate & date)

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

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp