#ifndef MAINWINDOW_H
#define MAINWINDOW_H #include <QMainWindow>
#include <QDateTime>
#include <QDateTimeEdit> class MainWindow : public QMainWindow
{
Q_OBJECT public:
MainWindow(QWidget *parent = );
~MainWindow(); QDateTimeEdit* dt[] ;
}; #endif // MAINWINDOW_H
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->resize(,); // 按照指定格式显示日期时间
dt[] = new QDateTimeEdit(QDateTime::currentDateTime(),this);
dt[]->setDisplayFormat("yyyy-MM-dd hh:mm:ss:zzz");
dt[]->setGeometry(,,,);
// 指定时间微调范围,年月日都只可以调动2
dt[] = new QDateTimeEdit(QDateTime::currentDateTime(),this);
dt[]->setMaximumDateTime(QDateTime::currentDateTime().addYears());
dt[]->setMinimumDateTime(QDateTime::currentDateTime().addYears(-));
dt[]->setDisplayFormat("yyyy");
dt[]->setGeometry(,,,); dt[] = new QDateTimeEdit(QDateTime::currentDateTime(),this);
dt[]->setMaximumDateTime(QDateTime::currentDateTime().addMonths());
dt[]->setMinimumDateTime(QDateTime::currentDateTime().addMonths(-));
dt[]->setDisplayFormat("MM");
dt[]->setGeometry(,,,); dt[] = new QDateTimeEdit(QDateTime::currentDateTime(),this);
dt[]->setMaximumDateTime(QDateTime::currentDateTime().addDays());
dt[]->setMinimumDateTime(QDateTime::currentDateTime().addDays(-));
dt[]->setDisplayFormat("dd");
dt[]->setGeometry(,,,);
} MainWindow::~MainWindow()
{ }
#include "mainwindow.h"
#include <QApplication> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show(); return a.exec();
}

QT5控件-QDateTimeEdit和类QDateTime的更多相关文章

  1. 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing

    [源码下载] 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing 作者:webabcd 介绍背水一 ...

  2. 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch

    [源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...

  3. 背水一战 Windows 10 (32) - 控件(选择类): Selector, ComboBox

    [源码下载] 背水一战 Windows 10 (32) - 控件(选择类): Selector, ComboBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(选择类) Sel ...

  4. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  5. 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox

    [源码下载] 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) AutoSug ...

  6. 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox

    [源码下载] 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox 作者:webabcd ...

  7. 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox

    [源码下载] 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) T ...

  8. 背水一战 Windows 10 (27) - 控件(文本类): TextBlock

    [源码下载] 背水一战 Windows 10 (27) - 控件(文本类): TextBlock 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) TextBlock 示例 ...

  9. iOS控件之UIResponder类

    iOS控件之UIResponder类 在iOS中UIResponder类是专门用来响应用户的操作处理各种事件的,我们知道UIApplication.UIView.UIViewController这几个 ...

随机推荐

  1. C语言学习笔记--字符串函数

    字符串函数 需要包含头文件#include<stdio.h> strlen strcmp strcpy strchr strstr strcasestr

  2. EventSystem

    Unity5.0 EventSystem事件系统的详细说明 一.EventSystem对象的说明 当我们在场景中创建任一UI对象后,Hierarchy面板中都可以看到系统自动创建了对象EventSys ...

  3. jquery $.each() 小探

    <html> <head> <title> jquery each使用 </title> <script type='text/javascrip ...

  4. COJ 0200 Fibonacci

    传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=200 试题描述: 地球人都知道Fibonicca数列: 1 1 2 3 5 ...

  5. Buy the Ticket HDU 1133 递推+大数

    题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目大意: 有m+n个人去买电影票,每张电影票50元,  m个人是只有50元一张的,  n个人 ...

  6. 【动态规划】HDU 1081 & XMU 1031 To the Max

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1081 http://acm.xmu.edu.cn/JudgeOnline/problem.php?i ...

  7. C#之VS2010ASP.NET页面调用Web Service和winform程序调用Web Service

    一:用ASP.NET调用Web Service 打开VS2010,打开“文件-新建-网站”,选择“ASP.NET网站” 选好存储位置,语言后点击确定,进入默认页面.然后先添加Web引用,把WebSer ...

  8. shell中$0,$?,$!等的特殊用法【转载】

    本文转载自:http://blog.sina.com.cn/s/blog_464f6dba0100psy9.html ----------------------------------------- ...

  9. C++ STL之map常用指令

    只记载本人在ACM中常用的函数. map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力. map内部为一颗 ...

  10. linux系统资源信息监控

    系统 # uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # ho ...