Namespaces
Variants
Actions

Archived:How to use QCalendar

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

This (archived) code snippet demonstrates how to use the Qt calendar widget (QCalendar).

Article Metadata

Tested with
Devices(s): Symbian emulator

Platform Security
Signing Required: Self-Signed
Capabilities: None

Article
Keywords: QCalendar, Push Button
Created: james1980 (07 Jan 2009)
Last edited: hamishwillee (11 Oct 2012)

Various Functions

  • This property holds the format of the vertical header.
QCalendarWidget *calendar = new QCalendarWidget;
calendar->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
  • This property holds whether the date edit popup is enabled.When the widget is focus and then press any non-modifier key will cause a date edit to popup.
QCalendarWidget *calendar = new QCalendarWidget;
calendar->setDateEditEnabled(1);

Calender1.JPG

  • Property holds a value identifying the day displayed in the first column.
QCalendarWidget *calendar = new QCalendarWidget;
calendar->setFirstDayOfWeek(Qt::Wednesday);

Calender2.JPG


Source File

#include <QCalendarWidget>
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <QWindowsStyle>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *win = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;
QPushButton *nextyrbutton = new QPushButton("Next Year");
QPushButton *prevyrbutton = new QPushButton("Prev Year");
QCalendarWidget *calendar = new QCalendarWidget;
QObject::connect(nextyrbutton,SIGNAL(clicked()),calendar,SLOT(showNextYear()));
QObject::connect(prevyrbutton,SIGNAL(clicked()),calendar,SLOT(showPreviousYear()));
layout->addWidget(calendar);
layout->addWidget(prevyrbutton);
layout->addWidget(nextyrbutton);
calendar->setGridVisible(true);
win->setLayout(layout);
win->showNormal();
 
return app.exec();
}
  • In the above example only two function for displaying next and previous year are used but there are many other function like showNextMonth,show PreviousMonth,showToday etc...

Screenshot

Calender.JPG

This page was last modified on 11 October 2012, at 04:14.
323 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved