|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QCalendarWidget
public class QCalendarWidget
The QCalendarWidget
class provides a monthly based calendar widget allowing the user to select a date.
QCalendarWidget
provides several public slots to change the year and month that is shown. The currently displayed month and year can be retrieved using the currentPageMonth() and currentPageYear() functions, respectively. By default, today's date is selected, and the user can select a date using both mouse and keyboard. The currently selected date can be retrieved using the selectedDate()
function. It is possible to constrain the user selection to a given date range by setting the minimumDate
and maximumDate
properties. Alternatively, both properties can be set in one go using the setDateRange()
convenience slot. Set the selectionMode
property to NoSelection
to prohibit the user from selecting at all. Note that a date also can be selected programmatically using the setSelectedDate()
slot.
A newly created calendar widget uses abbreviated day names, and both Saturdays and Sundays are marked in red. The calendar grid is not visible. The week numbers are displayed, and the first column day is Sunday.
The notation of the days can be altered to a single letter abbreviations ("M" for "Monday") by setting the horizontalHeaderFormat
property to QCalendarWidget::SingleLetterDayNames
. Setting the same property to QCalendarWidget::LongDayNames
makes the header display the complete day names. The week numbers can be removed by setting the verticalHeaderFormat
property to QCalendarWidget::NoVerticalHeader
. The calendar grid can be turned on by setting the gridVisible
property to true using the setGridVisible()
function:
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); |
setFirstDayOfWeek()
function. The QCalendarWidget
class also provides three signals, selectionChanged()
, activated()
and currentPageChanged()
making it possible to respond to user interaction.
The rendering of the headers, weekdays or single days can be largely customized by setting QTextCharFormat
's for some special weekday, a special date or for the rendering of the headers.
Only a subset of the properties in QTextCharFormat
are used by the calendar widget. Currently, the foreground, background and font properties are used to determine the rendering of individual cells in the widget.
QDate
, QDateEdit
, and QTextCharFormat
.
Nested Class Summary | |
---|---|
static class |
QCalendarWidget.HorizontalHeaderFormat
This enum type defines the various formats the horizontal header can display. |
static class |
QCalendarWidget.SelectionMode
This enum describes the types of selection offered to the user for selecting dates in the calendar. |
static class |
QCalendarWidget.VerticalHeaderFormat
This enum type defines the various formats the vertical header can display. |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
activated
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
clicked
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal2 |
currentPageChanged
This signal takes 2 generic argument(s). |
QSignalEmitter.Signal0 |
selectionChanged
This signal is emitted when the currently selected date is changed. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QCalendarWidget()
Constructs a calendar widget with the given parent. |
|
QCalendarWidget(QWidget parent)
Constructs a calendar widget with the given parent. |
Method Summary | |
---|---|
int |
dateEditAcceptDelay()
This property holds the time an inactive date edit is shown before its contents are accepted. |
java.util.SortedMap |
dateTextFormat()
Returns a QMap from QDate to QTextCharFormat showing all dates that use a special format that alters their rendering. |
QTextCharFormat |
dateTextFormat(QDate date)
Returns a QTextCharFormat for date. |
Qt.DayOfWeek |
firstDayOfWeek()
This property holds a value identifying the day displayed in the first column. |
QTextCharFormat |
headerTextFormat()
Returns the text char format for rendering the header. |
QCalendarWidget.HorizontalHeaderFormat |
horizontalHeaderFormat()
This property holds the format of the horizontal header. |
boolean |
isDateEditEnabled()
This property holds whether the date edit popup is enabled. |
boolean |
isGridVisible()
This property holds whether the table grid is displayed. |
boolean |
isNavigationBarVisible()
This property holds whether the navigation bar is shown or not. |
QDate |
maximumDate()
This property holds the maximum date of the currently specified date range. |
QDate |
minimumDate()
This property holds the minimum date of the currently specified date range. |
int |
monthShown()
Returns the currently displayed month. |
protected void |
paintCell(QPainter painter,
QRect rect,
QDate date)
Paints the cell specified by the given date, using the given painter and rect. |
QDate |
selectedDate()
This property holds the currently selected date. |
QCalendarWidget.SelectionMode |
selectionMode()
This property holds the type of selection the user can make in the calendar. |
void |
setCurrentPage(int year,
int month)
Displays the given month of the given year without changing the selected date. |
void |
setDateEditAcceptDelay(int delay)
This property holds the time an inactive date edit is shown before its contents are accepted. |
void |
setDateEditEnabled(boolean enable)
This property holds whether the date edit popup is enabled. |
void |
setDateRange(QDate min,
QDate max)
Defines a date range by setting the minimumDate and maximumDate properties. |
void |
setDateTextFormat(QDate date,
QTextCharFormat format)
Sets the format used to render the given date to that specified by format. |
void |
setFirstDayOfWeek(Qt.DayOfWeek dayOfWeek)
This property holds a value identifying the day displayed in the first column. |
void |
setGridVisible(boolean show)
This property holds whether the table grid is displayed. |
void |
setHeaderTextFormat(QTextCharFormat format)
Sets the text char format for rendering the header to format. |
void |
setHorizontalHeaderFormat(QCalendarWidget.HorizontalHeaderFormat format)
This property holds the format of the horizontal header. |
void |
setMaximumDate(QDate date)
This property holds the maximum date of the currently specified date range. |
void |
setMinimumDate(QDate date)
This property holds the minimum date of the currently specified date range. |
void |
setNavigationBarVisible(boolean visible)
This property holds whether the navigation bar is shown or not. |
void |
setSelectedDate(QDate date)
This property holds the currently selected date. |
void |
setSelectionMode(QCalendarWidget.SelectionMode mode)
This property holds the type of selection the user can make in the calendar. |
void |
setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat format)
This property holds the format of the vertical header. |
void |
setWeekdayTextFormat(Qt.DayOfWeek dayOfWeek,
QTextCharFormat format)
Sets the text char format for rendering of day in the week dayOfWeek to format. |
void |
showNextMonth()
Shows the next month relative to the currently displayed month. |
void |
showNextYear()
Shows the currently displayed month in the next year relative to the currently displayed year. |
void |
showPreviousMonth()
Shows the previous month relative to the currently displayed month. |
void |
showPreviousYear()
Shows the currently displayed month in the previous year relative to the currently displayed year. |
void |
showSelectedDate()
Shows the month of the selected date. |
void |
showToday()
Shows the month of the today's date. |
protected void |
updateCell(QDate date)
Updates the cell specified by the given date unless updates are disabled or the cell is hidden. |
protected void |
updateCells()
Updates all visible cells unless updates are disabled. |
QCalendarWidget.VerticalHeaderFormat |
verticalHeaderFormat()
This property holds the format of the vertical header. |
QTextCharFormat |
weekdayTextFormat(Qt.DayOfWeek dayOfWeek)
Returns the text char format for rendering of day in the week dayOfWeek. |
int |
yearShown()
Returns the year of the currently displayed month. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 activated
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QDate(named: date)>:
This signal is emitted whenever the user presses the Return or Enter key or double-clicks a date in the calendar widget.
public final QSignalEmitter.Signal1 clicked
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QDate(named: date)>:
This signal is emitted when a mouse button is clicked. The date the mouse was clicked on is specified by date. The signal is only emitted when clicked on a valid date.
public final QSignalEmitter.Signal2 currentPageChanged
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: year), java.lang.Integer(named: month)>:
This signal is emitted when the currently shown month is changed. The new year and month are passed as parameters.
setCurrentPage()
.
public final QSignalEmitter.Signal0 selectionChanged
The currently selected date can be changed by the user using the mouse or keyboard, or by the programmer using setSelectedDate()
.
selectedDate()
.
Constructor Detail |
---|
public QCalendarWidget()
The widget is initialized with the current month and year, and the currently selected date is today.
setCurrentPage()
.
public QCalendarWidget(QWidget parent)
The widget is initialized with the current month and year, and the currently selected date is today.
setCurrentPage()
.
Method Detail |
---|
public final int dateEditAcceptDelay()
date edit is enabled
, this property specifies the amount of time (in millseconds) that the date edit remains open after the most recent user input. Once this time has elapsed, the date specified in the date edit is accepted and the popup is closed. By default, the delay is defined to be 1500 milliseconds (1.5 seconds).
public final java.util.SortedMap dateTextFormat()
QDate
to QTextCharFormat
showing all dates that use a special format that alters their rendering. setDateTextFormat()
.
public final QTextCharFormat dateTextFormat(QDate date)
QTextCharFormat
for date. The char format can be be empty if the date is not renderd specially.
public final Qt.DayOfWeek firstDayOfWeek()
public final QTextCharFormat headerTextFormat()
setHeaderTextFormat()
.
public final QCalendarWidget.HorizontalHeaderFormat horizontalHeaderFormat()
QCalendarWidget::ShortDayNames
.
public final boolean isDateEditEnabled()
By default, this property is enabled.
The date edit is simpler in appearance than QDateEdit
, but allows the user to navigate between fields using the left and right cursor keys, increment and decrement individual fields using the up and down cursor keys, and enter values directly using the number keys.
QCalendarWidget::dateEditAcceptDelay
.
public final boolean isGridVisible()
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); |
public final boolean isNavigationBarVisible()
When the property is set to false, these controls are hidden.
public final QDate maximumDate()
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); calendar.setMaximumDate(new QDate(2006, 7, 3)); |
QDate
class can handle. When setting a maximum date, the minimumDate
and selectedDate
properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate
object, the setMaximumDate()
function does nothing.
setDateRange()
.
public final QDate minimumDate()
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); calendar.setMinimumDate(new QDate(2006, 6, 19)); |
QDate
class can handle. When setting a minimum date, the maximumDate
and selectedDate
properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate
object, the setMinimumDate()
function does nothing.
setDateRange()
.
public final int monthShown()
yearShown()
, and setCurrentPage()
.
public final QDate selectedDate()
minimumDate
and maximumDate
properties. By default, the selected date is the current date. setDateRange()
.
public final QCalendarWidget.SelectionMode selectionMode()
SingleSelection
, the user can select a date within the minimum and maximum allowed dates, using either the mouse or the keyboard. When the property is set to NoSelection
, the user will be unable to select dates, but they can still be selected programmatically. Note that the date that is selected when the property is set to NoSelection
will still be the selected date of the calendar.
The default value is SingleSelection
.
public final void setCurrentPage(int year, int month)
setSelectedDate()
function to alter the selected date. The currently displayed month and year can be retrieved using the currentPageMonth() and currentPageYear() functions respectively.
yearShown()
, monthShown()
, showPreviousMonth()
, showNextMonth()
, showPreviousYear()
, and showNextYear()
.
public final void setDateEditAcceptDelay(int delay)
date edit is enabled
, this property specifies the amount of time (in millseconds) that the date edit remains open after the most recent user input. Once this time has elapsed, the date specified in the date edit is accepted and the popup is closed. By default, the delay is defined to be 1500 milliseconds (1.5 seconds).
public final void setDateEditEnabled(boolean enable)
By default, this property is enabled.
The date edit is simpler in appearance than QDateEdit
, but allows the user to navigate between fields using the left and right cursor keys, increment and decrement individual fields using the up and down cursor keys, and enter values directly using the number keys.
QCalendarWidget::dateEditAcceptDelay
.
public final void setDateRange(QDate min, QDate max)
minimumDate
and maximumDate
properties. The date range restricts the user selection, i.e. the user can only select dates within the specified date range. Note that
QCalendarWidget calendar = new QCalendarWidget(); calendar.setDateRange(min, max);is analogous to
QCalendarWidget calendar = new QCalendarWidget(); calendar.setMinimumDate(min); calendar.setMaximumDate(max);If either the min or max parameters are not valid
QDate
objects, this function does nothing. setMinimumDate()
, and setMaximumDate()
.
public final void setDateTextFormat(QDate date, QTextCharFormat format)
If date is null, all date formats are cleared.
dateTextFormat()
.
public final void setFirstDayOfWeek(Qt.DayOfWeek dayOfWeek)
public final void setGridVisible(boolean show)
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); |
public final void setHeaderTextFormat(QTextCharFormat format)
headerTextFormat()
.
public final void setHorizontalHeaderFormat(QCalendarWidget.HorizontalHeaderFormat format)
QCalendarWidget::ShortDayNames
.
public final void setMaximumDate(QDate date)
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); calendar.setMaximumDate(new QDate(2006, 7, 3)); |
QDate
class can handle. When setting a maximum date, the minimumDate
and selectedDate
properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate
object, the setMaximumDate()
function does nothing.
setDateRange()
.
public final void setMinimumDate(QDate date)
![]() |
QCalendarWidget calendar = new QCalendarWidget(); calendar.setGridVisible(true); calendar.setMinimumDate(new QDate(2006, 6, 19)); |
QDate
class can handle. When setting a minimum date, the maximumDate
and selectedDate
properties are adjusted if the selection range becomes invalid. If the provided date is not a valid QDate
object, the setMinimumDate()
function does nothing.
setDateRange()
.
public final void setNavigationBarVisible(boolean visible)
When the property is set to false, these controls are hidden.
public final void setSelectedDate(QDate date)
minimumDate
and maximumDate
properties. By default, the selected date is the current date. setDateRange()
.
public final void setSelectionMode(QCalendarWidget.SelectionMode mode)
SingleSelection
, the user can select a date within the minimum and maximum allowed dates, using either the mouse or the keyboard. When the property is set to NoSelection
, the user will be unable to select dates, but they can still be selected programmatically. Note that the date that is selected when the property is set to NoSelection
will still be the selected date of the calendar.
The default value is SingleSelection
.
public final void setVerticalHeaderFormat(QCalendarWidget.VerticalHeaderFormat format)
public final void setWeekdayTextFormat(Qt.DayOfWeek dayOfWeek, QTextCharFormat format)
weekdayTextFormat()
, and setHeaderTextFormat()
.
public final void showNextMonth()
showPreviousMonth()
, setCurrentPage()
, and setSelectedDate()
.
public final void showNextYear()
showPreviousYear()
, setCurrentPage()
, and setSelectedDate()
.
public final void showPreviousMonth()
showNextMonth()
, setCurrentPage()
, and setSelectedDate()
.
public final void showPreviousYear()
showNextYear()
, setCurrentPage()
, and setSelectedDate()
.
public final void showSelectedDate()
selectedDate()
, and setCurrentPage()
.
public final void showToday()
selectedDate()
, and setCurrentPage()
.
protected final void updateCell(QDate date)
updateCells()
, yearShown()
, and monthShown()
.
protected final void updateCells()
updateCell()
.
public final QCalendarWidget.VerticalHeaderFormat verticalHeaderFormat()
public final QTextCharFormat weekdayTextFormat(Qt.DayOfWeek dayOfWeek)
setWeekdayTextFormat()
, and headerTextFormat()
.
public final int yearShown()
monthShown()
, and setCurrentPage()
.
protected void paintCell(QPainter painter, QRect rect, QDate date)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |