#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. Android Service 启动和停止服务

    activity_main.xml 定义两个Button控件,start_service和stop_service. <LinearLayout xmlns:android="http ...

  2. unwrap_uvw 笔记

    <integer><Unwrap_UVW>.numberVerticesByNode <node>node --返回图顶点的对应于给定节点的Unwrap_UVW点总 ...

  3. linux和windows下,C/C++的sleep函数

    简介: 函数名: sleep   功 能: 执行挂起一段时间   用 法: unsigned sleep(unsigned seconds);   在VC中使用带上头文件   #include < ...

  4. tomcat thread dump 分析【转载】

    前言 Java Thread Dump 是一个非常有用的应用诊断工具, 通过thread dump出来的信息, 可以定位到你需要了解的线程, 以及这个线程的调用栈. 如果配合linux的top命令, ...

  5. Java:Date、Calendar、Timestamp的区别、相互转换与使用【转载】

    1 Java.util.Date 包含年.月.日.时.分.秒信息 包含年.月.日信息. 继承自java.util.Date.在数据库相关操作中使用,如rs.getDate,ps.setDate等.rs ...

  6. python模块之bsddb: bdb高性能嵌入式数据库 1.基础知识

    转自:http://blog.csdn.net/zhaoweikid/article/details/1665741 bsddb模块是用来操作bdb的模块,bdb是著名的Berkeley DB,它的性 ...

  7. 港股street和nominee区别

    股票的street和nominee区别主要用在公司行动的过户费方面,street股票需要收取过户费,nominee不收过户费. street股票通过做公司行动收取过户费后会变成nominee股票,下次 ...

  8. 多态 JAVA

    多态(Java)   一.多态 1.什么是多态? 不同的对象对于同一个操作,做出的响应不同 具有表现多种形态的能力的特征 2.使用多态的优点 : 为了实现统一调用 二.子类到父类的转换(向上转型) ① ...

  9. Python使用mechanize模拟浏览器

    Python使用mechanize模拟浏览器 之前我使用自带的urllib2模拟浏览器去进行訪问网页等操作,非常多站点都会出错误,还会返回乱码.之后使用了 mechanize模拟浏览器,这些情况都没出 ...

  10. POJ3422 Kaka&#39;s Matrix Travels 【最大费用最大流】

    Kaka's Matrix Travels Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8006   Accepted:  ...