linux下qt制作日历,基于QT的多功能日历设计与开发.doc

基于QT的多功能日历设计与开发

上海电力学院

本科毕业设计(论文)

题  目: 基于QT的多功能日历

设计与开发

院  系:  计算机与信息工程学院

专业年级:  2007电子科学与技术

学生姓名:  张岚   学号:

指导教师:   金一鸣

2011年6月15日基于QT的多功能日历设计与开发

摘要 目前嵌入式系统技术已经成为了最热门的技术之一,吸引了大批的优秀人才投入其中但是对于何为嵌入式系统,什么样的技术又可以称之为嵌入式技术,仍在讨论之中。嵌入式Linux系统有代表性的GUI系统主要有MiniGUI、MicroWindows、Tiny X以及Qt/Embedded。Qt/Embedded,是一个专门为小型设备提供图形用户界面的应用框架和窗口系统。提供了丰富的窗口小部件(Widgets),并且还支持窗口部件的定制,因此它可以为用户提供漂亮的图形界面。Qt是 KDE 等项目使用的 GUI 支持库,所以有许多基于Qt 的 X Window 程序可以非常方便地移植到Qt/Embedded 版本上Embedded systems technology has now become one of the most popular technology, attracting a large number of talents involved in, but what is embedded systems, what kind of technology they can be called embedded technology, still under discussion.The three commonly used embedded operating systems are Palm OS, Windows CE and Linux, which Linux has become an ideal choice for embedded operation.Embedded Linux GUI system representative of the main MiniGUI, MicroWindows, Tiny X and Qt / Embedded.Which Qt / Embedded, designed for small devices is to provide a graphical user interface application framework and window systems.Providing a wealth of widgets (Widgets), and also supports custom widgets, so it can provide a nice graphical user interface.Qt is KDE and other projects to support the use of GUI libraries, so there are many Qt-based X Window programs can be very easily ported to Qt / Embedded version.This paper mainly introduced the QT-based graphical calendar interface multi-function design and development, it's interface and functionality is the same as the electronic calendar used in daily life.For example, it has the function of switching and changing the day of calendar, and a special date reminding events.These functions are based on the development of embedded graphical user interface.The following will be to discussion how to use QT code development and design of multi-function calendar, and how to compile the fin

//自定义日历可看上篇文章 QCalendarTimeEdit::QCalendarTimeEdit(QWidget *parent) : QLineEdit(parent) , m_calendarWidget(nullptr) , m_widget(nullptr) { m_minDateTime = QDateTime::currentDateTime(); { QTime maxtime; maxtime.setHMS(23, 59, 59); m_maxDateTime.setTime(maxtime); m_maxDateTime.setDate(QDate::currentDate().addDays(365)); } setContextMenuPolicy(Qt::NoContextMenu); } QCalendarTimeEdit::~QCalendarTimeEdit() { if (m_widget) { delete m_widget; m_widget = nullptr; } } void QCalendarTimeEdit::initControlcalendar() { m_widget = new BackPaintWidget(nullptr); m_widget->setObjectName("calendarFramWidget"); loadStyleSheet(m_widget, "CalendarWidget"); m_widget->setAttribute(Qt::WA_TranslucentBackground); m_widget->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::SubWindow); QHBoxLayout* layout = new QHBoxLayout; layout->setMargin(8); layout->setSpacing(0); m_calendarWidget = new QCustomCalendarTimeWidget(m_widget); m_widget->setCalendarTimeWidget(m_calendarWidget); m_calendarWidget->setCalendarMinDate(m_minDateTime); m_calendarWidget->setCalendarMaxDate(m_maxDateTime); //m_calendarWidget->disconnect(SIGNAL(selectionChanged())); //m_calendarWidget->disconnect(SIGNAL(clicked(QDate))); layout->addWidget(m_calendarWidget); m_widget->setLayout(layout); connect(m_calendarWidget, &QCustomCalendarTimeWidget;::signalSetCalendarTime, [this](const QDateTime& date){ setText(date.toString("yyyy-MM-dd hh:mm:ss")); hideCalendarTimeWidget(); }); connect(m_calendarWidget, &QCustomCalendarTimeWidget;::signalClearDateTime, [this](){ clear(); hideCalendarTimeWidget(); }); hideCalendarTimeWidget(); } void QCalendarTimeEdit::setCalendarMinDate(const QDateTime &datetime;) { m_minDateTime = datetime; if (m_calendarWidget) { m_calendarWidget->setCalendarMinDate(m_minDateTime); } } void QCalendarTimeEdit::setCalendarMaxDate(const QDateTime &datetime;) { m_maxDateTime = datetime; if (m_calendarWidget) { m_calendarWidget->setCalendarMaxDate(m_maxDateTime); } } void QCalendarTimeEdit::popCalendarTimeWidget() { if (m_calendarWidget == nullptr) { initControlcalendar(); } QRect rect = qApp->desktop()->availableGeometry(0); QPoint gloadPos = mapToGlobal(QPoint(-8, this->height())); if (gloadPos.y() + m_calendarWidget->height() > rect.height()) { int y = gloadPos.y() - this->height() - m_calendarWidget->height(); gloadPos.setY(y); } m_widget->move(gloadPos); m_widget->show(); } void QCalendarTimeEdit::hideCalendarTimeWidget() { m_widget->hide(); } void QCalendarTimeEdit::mousePressEvent(QMouseEvent *event) { __super::mousePressEvent(event); if (event->button() == Qt::LeftButton) { popCalendarTimeWidget(); } } void QCalendarTimeEdit::keyPressEvent(QKeyEvent *event) { Q_UNUSED(event); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值