返回介绍

QDateTimeEdit Class

发布于 2019-10-04 14:59:23 字数 5149 浏览 1189 评论 0 收藏 0

The QDateTimeEdit class combines a QDateEdit and QTimeEdit widget into a single widget for editing datetimes. More...

#include <qdatetimeedit.h>

Inherits QWidget.

List of all member functions.

Public Members

  • QDateTimeEdit ( QWidget*parent = 0, constchar*name = 0 )
  • QDateTimeEdit ( constQDateTime&datetime, QWidget*parent = 0, constchar*name = 0 )
  • ~QDateTimeEdit ()
  • virtual void setDateTime ( constQDateTime&dt )
  • QDateTime dateTime () const
  • QDateEdit * dateEdit ()
  • QTimeEdit * timeEdit ()
  • virtual void setAutoAdvance ( booladvance )
  • bool autoAdvance () const

Signals

  • void valueChanged ( constQDateTime&datetime )

Properties

  • QDateTime dateTime- the datetime value of the editor

Detailed Description

The QDateTimeEdit class combines a QDateEdit and QTimeEdit widget into a single widget for editing datetimes.

QDateTimeEdit consists of a QDateEdit and QTimeEdit widget placed side by side and offers the functionality of both. The user can edit the date and time by using the keyboard or the arrow keys to increase/decrease date or time values. The Tab key can be used to move from section to section within the QDateTimeEdit widget, and the user can be moved automatically when they complete a section using setAutoAdvance(). The datetime can be set with setDateTime().

The dateformat is read from the system's locale settings. It is set to year, month, day order if that is not possible. see QDateEdit::setOrder() to change this. Times appear in the order hours, minutes, seconds using the 24 hour clock.

It is recommended that the QDateTimeEdit is initialised with a datetime, e.g.

    QDateTimeEdit *dateTimeEdit = new QDateTimeEdit( QDateTime::currentDateTime(), this );
    dateTimeEdit->dateEdit()->setRange( QDateTime::currentDate(),
                                        QDateTime::currentDate().addDays( 7 ) );
    
Here we've created a new QDateTimeEdit set to the current date and time, and set the date to have a minimum date of now and a maximum date of a week from now.

Terminology: A QDateEdit widget consists of three 'sections', one each for the year, month and day. Similarly a QTimeEdit consists of three sections, one each for the hour, minute and second. The character that separates each date section is specified with setDateSeparator(); similarly setTimeSeparator() is used for the time sections.

Date Time Widgets

See also QDateEdit, QTimeEdit, Advanced Widgets and Time and Date.


Member Function Documentation

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

Constructs an empty datetime edit with parent parent and name name.

QDateTimeEdit::QDateTimeEdit ( constQDateTime&datetime, QWidget*parent = 0, constchar*name = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Constructs a datetime edit with the initial value datetime, parent parent and name name.

QDateTimeEdit::~QDateTimeEdit ()

Destroys the object and frees any allocated resources.

bool QDateTimeEdit::autoAdvance () const

Returns TRUE if auto-advance is enabled, otherwise returns FALSE.

See also setAutoAdvance().

QDateEdit* QDateTimeEdit::dateEdit ()

Returns the internal widget used for editing the date part of the datetime.

QDateTime QDateTimeEdit::dateTime () const

Returns the datetime value of the editor. See the "dateTime" property for details.

void QDateTimeEdit::setAutoAdvance ( booladvance ) [virtual]

Sets the auto advance property of the editor to advance. If set to TRUE, the editor will automatically advance focus to the next date or time section if the user has completed a section.

void QDateTimeEdit::setDateTime ( constQDateTime&dt ) [virtual]

Sets the datetime value of the editor to dt. See the "dateTime" property for details.

QTimeEdit* QDateTimeEdit::timeEdit ()

Returns the internal widget used for editing the time part of the datetime.

void QDateTimeEdit::valueChanged ( constQDateTime&datetime ) [signal]

This signal is emitted every time the date or time changes. The datetime argument is the new datetime.


Property Documentation

QDateTime dateTime

This property holds the datetime value of the editor.

The datetime edit's datetime which may be an invalid datetime.

Set this property's value with setDateTime() and get this property's value with dateTime().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文