QtGui.QCalendarWidget
A QtGui.QCalendarWidget provides a monthly based calendar widget. It allows a user to select a date in a simple and intuitive way.
#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial This example shows a QtGui.QCalendarWidget widget. author: Jan Bodnar
website: zetcode.com
last edited: September 2011
""" import sys
from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self):
super(Example, self).__init__() self.initUI() def initUI(self): cal = QtGui.QCalendarWidget(self)
cal.setGridVisible(True)
cal.move(20, 20)
cal.clicked[QtCore.QDate].connect(self.showDate) self.lbl = QtGui.QLabel(self)
date = cal.selectedDate()
self.lbl.setText(date.toString())
self.lbl.move(130, 260) self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Calendar')
self.show() def showDate(self, date): self.lbl.setText(date.toString()) def main(): app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) if __name__ == '__main__':
main()
The example has a calendar widget and a label widget. The currently selected date is displayed in the label widget.
cal = QtGui.QCalendarWidget(self)
We construct a calendar widget.
cal.clicked[QtCore.QDate].connect(self.showDate)
If we select a date from the widget, a clicked[QtCore.QDate] signal is emitted. We connect this signal to the user defined showDate() method.
def showDate(self, date):
self.lbl.setText(date.toString())
We retrieve the selected date by calling the selectedDate() method. Then we transform the date object into string and set it to the label widget.
Figure: QtGui.QCalendarWidget
QtGui.QCalendarWidget的更多相关文章
- Qt4升级Qt5注意问题
Qt4升级Qt5注意问题 Qt4过渡到Qt5的项目一开始就受阻,记录一下遇到的下面的问题 --->编译遇到类似错误: error: QCalendarWidget: No such file o ...
- PyQt4日历部件QXalendarWidget
QCalendarWidget类提供了以月为单位地日历部件.该部件允许用户以一种简单而直接的方式选择日期. #!/usr/bin/python # -*- coding: utf-8 -*- impo ...
- ZetCode PyQt4 tutorial widgets I
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...
- PyQt4 进度条和日历 代码
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Na ...
- 读Pyqt4教程,带你入门Pyqt4 _008
QCalendarWidget QCalendarWidget 提供基于月份的日历窗口组件,它允许用户简单并且直观的选择日期. #!/usr/bin/python # -*- coding: utf- ...
- GUI学习之三十—QCalendarWidget学习总结
今天学习的是最后一个展示控件——QCalendarWidget 一.描述 QCalendarWidget提供了一个基于每月的日历控件,允许用户选择一个日期,还可以看一下里面的图示: QCalendar ...
- PySide中QtGui.QFrame的用法
最近一位同事的出现让我重新正视PySide中designer这个工具的强大之处,通过QtGui.QObject.setGeometry(QtCore.QRect())这个最简单直接的方法可以完成很多复 ...
- 【PyQt5-Qt Designer】日历(QCalendarWidget)
日历(QCalendarWidget)+爬虫API调用+自定义发送信号(传入2个参数) 总体介绍 QCalendarWidget类提供了一个基日历小部件,允许用户选择一个日期. 该小部件使用当前的月份 ...
- QT5中无法包含Qtgui头文件的问题。
今天新学QT是,从一个ppt中边看边抄边学.前几页还能理解,但到了用纯源码写空白QT工程时,便遇到了一个问题.头文件里包含 #include <QtGui> 但是编译时总是出现下面图一中 ...
随机推荐
- herbinate 数据库乱码
改jdbc或者hibernate编码: jdbc:mysql://127.0.0.1:3306/db?useUnicode=true&characterEncoding=utf-8 ...
- CSS 笔记——列表表格
6. 列表表格 -> 列表 (1)list-style 基本语法 list-style : list-style-image || list-style-position || list-sty ...
- [BZOJ4247]挂饰(DP)
当最终挂饰集合确定了,一定是先挂挂钩多的在挂挂钩少的. 于是按挂钩从大到小排序,然后就是简单的01背包. #include<cstdio> #include<algorithm> ...
- codevs 3160 最长公共子串 后缀自动机
http://codevs.cn/problem/3160/ 后缀自动机板子题,匹配的时候要注意如果到一个点失配向前匹配到一个点时,此时的tmp(当前匹配值)为t[j].len+1而不是t[t[j]. ...
- 【可持久化并查集】BZOJ3673-可持久化并查集 by zky
颓了十多天别问我再干嘛,在补学校作业 啊,开学了……我的夏天…… [题目大意] n个集合 m个操作 操作: 1 a b 合并a,b所在集合 2 k 回到第k次操作之后的状态(查询算作操作) 3 a b ...
- 修改npm仓库地址
在C:\Users\Administrator文件夹下找到.npmrc 添加registry = http://registry.cnpmjs.org淘宝镜像地址,保存
- Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Connectio
严重: StandardWrapper.Throwableorg.springframework.transaction.CannotCreateTransactionException: Could ...
- CISC RISC架构
参考: http://capacity.blog.163.com/blog/static/20866413120129261737102/ http://cs.stanford.edu/people/ ...
- ArcGIS Engine中空间参照(地理坐标)相关方法总结转
ArcGIS Engine中空间参照(地理坐标)相关方法总结 来自:http://blog.csdn.net/u011170962/article/details/38776101 1.创建空间参考 ...
- 替换Android系统镜像system.img的方法
之前改动了Android的系统源代码的framework层代码,定制ROM.通过make之后会生成三个镜像文件userdata.img.system.img.ramdisk.img三个文件.这个时候我 ...