Qt:Документация 4.3.2/qdatetimeedit

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QDateTimeEdit Class Reference
[модуль QtGui ]

The QDateTimeEdit class provides a widget for editing dates and times. More...

 #include <QDateTimeEdit>

Inherits QAbstractSpinBox.

Inherited by QDateEdit and QTimeEdit.

[править] Открытые типы

  • enum Section { NoSection, AmPmSection, MSecSection, SecondSection, ..., YearSection }
  • flags Sections

[править] Свойства

  • 11 свойства унаследованных от QAbstractSpinBox
  • 56 свойства унаследованных от QWidget
  • 1 свойство унаследованное от QObject

[править] Открытые функции

  • 24 открытых функций унаследованных от QAbstractSpinBox
  • 201 открытых функций унаследованных от QWidget
  • 29 открытых функций унаследованных от QObject
  • 12 открытых функций унаследованных от QPaintDevice

[править] Открытые слоты

  • 4 открытых слотов унаследованных от QAbstractSpinBox
  • 19 открытых слотов унаследованных от QWidget
  • 1 открытый слот унаследованный от QObject

[править] Сигналы

  • 1 сигнал унаследованный от QAbstractSpinBox
  • 1 сигнал унаследованный от QWidget
  • 1 сигнал унаследованный от QObject

[править] Защищенные функции

  • 4 защищенных функций унаследованных от QAbstractSpinBox
  • 38 защищенных функций унаследованных от QWidget
  • 7 защищенных функций унаследованных от QObject
  • 1 защищенная функция унаследованна от QPaintDevice

[править] Дополнительные унаследованные члены

  • 4 статических открытых члена унаследованных от QWidget
  • 5 статических открытых члена унаследованных от QObject
  • 1 защищенный слот унаследованный от QWidget

[править] Подробное описание

The QDateTimeEdit class provides a widget for editing dates and times.

QDateTimeEdit allows the user to edit dates by using the keyboard or the arrow keys to increase and decrease date and time values. The arrow keys can be used to move from section to section within the QDateTimeEdit box. Dates and times appear in accordance with the format set; see setDisplayFormat().

 QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
 dateEdit->setMinimumDate(QDate::currentDate().addDays(-365));
 dateEdit->setMaximumDate(QDate::currentDate().addDays(365));
 dateEdit->setDisplayFormat("yyyy.MM.dd");

Here we've created a new QDateTimeEdit object initialized 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.

The minimum value for QDateTimeEdit is 14 September 1752, and 2 January 4713BC for QDate. You can change this by calling setMinimumDate(), setMaximumDate(), setMinimumTime(), and setMaximumTime().


center A date time editing widget shown in the Windows XP widget style.
center A date time editing widget shown in the Macintosh widget style.
Файл:Plastique-datetimeedit.png A date time editing widget shown in the Plastique widget style.

See also QDateEdit, QTimeEdit, QDate, and QTime.


[править] Описание типов членов

[править]
enum QDateTimeEdit::Section
flags QDateTimeEdit::Sections

Constant Value
QDateTimeEdit::NoSection 0x0000
QDateTimeEdit::AmPmSection 0x0001
QDateTimeEdit::MSecSection 0x0002
QDateTimeEdit::SecondSection 0x0004
QDateTimeEdit::MinuteSection 0x0008
QDateTimeEdit::HourSection 0x0010
QDateTimeEdit::DaySection 0x0100
QDateTimeEdit::MonthSection 0x0200
QDateTimeEdit::YearSection 0x0400

The Sections type is a typedef for QFlags<Section>. It stores an OR combination of Section values.


[править] Описание свойств

[править]
calendarPopup : bool

This property holds the current calender popup showing mode.

The calendar popup will be shown upon clicking the arrow button. This property is valid only if there is a valid date display format.

This property was introduced in Qt 4.2.

Функции доступа:

  • bool calendarPopup () const
  • void setCalendarPopup ( bool enable )

See also setDisplayFormat().

[править]
currentSection : Section

This property holds the current section of the spinbox setCurrentSection().

Функции доступа:

  • Section currentSection () const
  • void setCurrentSection ( Section section )

[править]
currentSectionIndex : int

This property holds the current section index of the spinbox.

If the format is 'yyyy/MM/dd', the displayText is '2001/05/21' and the cursorPosition is 5 currentSectionIndex returns 1. If the cursorPosition is 3 currentSectionIndex is 0 etc.

setCurrentSection()

This property was introduced in Qt 4.3.

Функции доступа:

  • int currentSectionIndex () const
  • void setCurrentSectionIndex ( int index )

See also currentSection().

[править]
date : QDate

This property holds the QDate that is set in the QDateTimeEdit.

Функции доступа:

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

See also time.

[править]
dateTime : QDateTime

This property holds the QDateTime that is set in the QDateTimeEdit.

Функции доступа:

  • QDateTime dateTime () const
  • void setDateTime ( const QDateTime & dateTime )

See also minimumDate, minimumTime, maximumDate, and maximumTime.

[править]
displayFormat : QString

This property holds the format used to display the time/date of the date time edit.

This format is the same as the one used described in QDateTime::toString() and QDateTime::fromString()

Example format strings(assuming that the date is 2nd of July 1969):


Format Result
dd.MM.yyyy 02.07.1969
MMM d yy Jul 2 69
MMMM d yy July 2 69

If you specify an invalid format the format will not be set.

Функции доступа:

  • QString displayFormat () const
  • void setDisplayFormat ( const QString & format )

See also QDateTime::toString() and displayedSections().

[править]
displayedSections : const Sections

This property holds the currently displayed fields of the date time edit.

Returns a bit set of the displayed sections for this format. setDisplayFormat(), displayFormat()

Функции доступа:

  • Sections displayedSections () const

[править]
maximumDate : QDate

This property holds the maximum date of the date time edit.

When setting this property the minimumDate is adjusted if necessary to ensure that the range remains valid. If the date is not a valid QDate object, this function does nothing.

Функции доступа:

  • QDate maximumDate () const
  • void setMaximumDate ( const QDate & max )
  • void clearMaximumDate ()

See also minimumDate, minimumTime, maximumTime, and setDateRange().

[править]
maximumTime : QTime

This property holds the maximum time of the date time edit.

When setting this property, the minimumTime is adjusted if necessary to ensure that the range remains valid. If the time is not a valid QTime object, this function does nothing.

Функции доступа:

  • QTime maximumTime () const
  • void setMaximumTime ( const QTime & max )
  • void clearMaximumTime ()

See also minimumTime, minimumDate, maximumDate, and setTimeRange().

[править]
minimumDate : QDate

This property holds the minimum date of the date time edit.

When setting this property the maximumDate is adjusted if necessary, to ensure that the range remains valid. If the date is not a valid QDate object, this function does nothing.

Функции доступа:

  • QDate minimumDate () const
  • void setMinimumDate ( const QDate & min )
  • void clearMinimumDate ()

See also minimumTime, maximumTime, and setDateRange().

[править]
minimumTime : QTime

This property holds the minimum time of the date time edit.

When setting this property the maximumTime is adjusted if necessary, to ensure that the range remains valid. If the time is not a valid QTime object, this function does nothing.

Функции доступа:

  • QTime minimumTime () const
  • void setMinimumTime ( const QTime & min )
  • void clearMinimumTime ()

See also maximumTime, minimumDate, maximumDate, and setTimeRange().

[править]
sectionCount : const int

This property holds the number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3.

This property was introduced in Qt 4.3.

Функции доступа:

  • int sectionCount () const

[править]
time : QTime

This property holds the QTime that is set in the QDateTimeEdit.

Функции доступа:

  • QTime time () const
  • void setTime ( const QTime & time )

See also date.


[править] Описание функций-членов

[править]
QDateTimeEdit::QDateTimeEdit ( QWidget * parent = 0 )

Constructs an empty date time editor with a parent.

[править]
QDateTimeEdit::QDateTimeEdit ( const QDateTime & datetime, QWidget * parent = 0 )

Constructs an empty date time editor with a parent. The value is set to datetime.

[править]
QDateTimeEdit::QDateTimeEdit ( const QDate & date, QWidget * parent = 0 )

Constructs an empty date time editor with a parent. The value is set to date.

[править]
QDateTimeEdit::QDateTimeEdit ( const QTime & time, QWidget * parent = 0 )

Constructs an empty date time editor with a parent. The value is set to time.

[править]
void QDateTimeEdit::dateChanged ( const QDate & date ) [signal]

This signal is emitted whenever the date is changed. The new date is passed in date.

[править]
void QDateTimeEdit::dateTimeChanged ( const QDateTime & datetime ) [signal]

This signal is emitted whenever the date or time is changed. The new date and time is passed in datetime.

[править]
QDateTime QDateTimeEdit::dateTimeFromText ( const QString & text ) const [virtual protected]

Returns an appropriate datetime for the given text.

This virtual function is used by the datetime edit whenever it needs to interpret text entered by the user as a value.

See also textFromDateTime() and validate().

[править]
void QDateTimeEdit::initStyleOption ( QStyleOptionSpinBox * option ) const [protected]

Initialize option with the values from this QDataTimeEdit. This method is useful for subclasses when they need a QStyleOptionSpinBox, but don't want to fill in all the information themselves.

See also QStyleOption::initFrom().

[править]
Section QDateTimeEdit::sectionAt ( int index ) const

Returns the Section at index.

If the format is 'yyyy/MM/dd', sectionAt(0) returns YearSection, sectionAt(1) returns MonthSection, and sectionAt(2) returns YearSection,

This function was introduced in Qt 4.3.

[править]
QString QDateTimeEdit::sectionText ( Section section ) const

Returns the text from the given section.

      1. note about not working when not Acceptable

See also currentSection().

[править]
void QDateTimeEdit::setDateRange ( const QDate & min, const QDate & max )

Convenience function to set minimum and maximum date with one function call.

 setDateRange(min, max);

is analogous to:

 setMinimumDate(min);
 setMaximumDate(max);

If either min or max are not valid, this function does nothing.

See also setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), and QDate::isValid().

[править]
void QDateTimeEdit::setSelectedSection ( Section section )

Selects section. If section doesn't exist in the currently displayed sections this function does nothing. If section is NoSection this function will unselect all text in the editor. Otherwise this function will move the cursor and the current section to the selected section.

This function was introduced in Qt 4.2.

See also currentSection().

[править]
void QDateTimeEdit::setTimeRange ( const QTime & min, const QTime & max )

Convenience function to set minimum and maximum time with one function call.

 setTimeRange(min, max);

is analogous to:

 setMinimumTime(min);
 setMaximumTime(max);

If either min or max are not valid, this function does nothing.

See also setMinimumDate(), maximumDate(), setMaximumDate(), clearMinimumDate(), setMinimumTime(), maximumTime(), setMaximumTime(), clearMinimumTime(), and QTime::isValid().

[править]
QString QDateTimeEdit::textFromDateTime ( const QDateTime & dateTime ) const [virtual protected]

This virtual function is used by the date time edit whenever it needs to display dateTime.

If you reimplement this, you may also need to reimplement valueFromText() and validate().

See also dateTimeFromText() and validate().

[править]
void QDateTimeEdit::timeChanged ( const QTime & time ) [signal]

This signal is emitted whenever the time is changed. The new time is passed in time.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2