1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QTimeEdit>
  6. #include <QTime>
  7.  
  8. class MainWindow : public QMainWindow
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. MainWindow(QWidget *parent = );
  14. ~MainWindow();
  15.  
  16. QTimeEdit* qte[];
  17. };
  18.  
  19. #endif // MAINWINDOW_H
  1. #include "mainwindow.h"
  2. #include <QtDebug>
  3.  
  4. MainWindow::MainWindow(QWidget *parent)
  5. : QMainWindow(parent)
  6. {
  7. this->resize(,);
  8. this->centralWidget();
  9. QTime ti1 = QTime(,,,);
  10. // 默认显示样式
  11. qte[] = new QTimeEdit(ti1,this);
  12. qte[]->setGeometry(,,,);
  13. // 指定格式显示样式
  14. qte[] = new QTimeEdit(ti1.addSecs(),this);
  15. qte[]->setGeometry(,,,);
  16. qte[]->setDisplayFormat("AP hh:mm:ss:zzz");
  17.  
  18. qte[] = new QTimeEdit(ti1.addMSecs(),this);
  19. qte[]->setGeometry(,,,);
  20. qte[]->setDisplayFormat("AP hh:mm:ss:zzz");
  21. // // 从字符串转化为时间
  22. QTime ti2 ;
  23. qte[] = new QTimeEdit(ti2.fromString("23:30:30","hh:mm:ss"),this);
  24. qte[]->setGeometry(,,,);
  25. qte[]->setDisplayFormat("AP hh:mm:ss:zzz");
  26. // 将日期转化为指定格式字符串
  27. qDebug()<<"当前时间"<<QTime::currentTime().toString("AP hh:mm:ss:zzz");
  28. // 计算过程时间
  29. QTime ti3 ;
  30. ti3.start();
  31. for(int i=;i<;i++)
  32. {
  33. for(int i=;i<;i++)
  34. {
  35.  
  36. }
  37. }
  38. qDebug()<<"刚刚经过了"<<ti3.elapsed()<<"毫秒";
  39. }
  40.  
  41. MainWindow::~MainWindow()
  42. {
  43.  
  44. }
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }

QT5-控件-QTimeEdit和QTime的更多相关文章

  1. QT5控件-QPushButton和QFocusFrame(按钮和焦点框)

    #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPushButton> ...

  2. QT5控件-QDateTimeEdit和类QDateTime

    #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDateTime> #i ...

  3. 日期与时间控件QDate, QTime, QDateTime

    QDate类用于处理公历日期.QTime类用于处理时间.QDateTime类将QDate对象和QTime对象整合为一个对象 QDate: from PyQt5.QtCore import QDate, ...

  4. Qt5学习笔记(控件)

    上面的程序仅仅可以显示一个 大概 的界面,对其进行单击等操作,界面仅有一些简单的反应,对应的程序不能得知界面有什么改变(是否进行单击选择,文本框中是否有文字输入) 下面对程序进行完善. T05Cont ...

  5. 我的QT5学习之路(三)——模板库、工具类和控件(下)

    一.前言 作为第三篇的最后一部分,我们来看一下Qt的控件,谈到控件,就会让人想到界面的美观性和易操作性,进而想到开发的便捷性.作为windows界面开发的MFC曾经是盛行了多少年,但是其弊端也随着其他 ...

  6. Qt5 UI信号、槽自动连接的控件重名

    Qt5 UI信号.槽自动连接的控件重名 来源 http://blog.csdn.net/goldenhawking/article/details/51865909 对Qt5稍有熟悉的童鞋都知道信号. ...

  7. Qt5 UI信号、槽自动连接的控件重名大坑(UI生成的槽函数存在一个隐患,即控件重名。对很复杂的控件,不要在 designer 里做提升,而是等到程序启动后,再动态创建,可以避免很多问题)

    对Qt5稍有熟悉的童鞋都知道信号.槽的自动连接机制.该机制使得qt designer 设计的UI中包含的控件,可以不通过显式connect,直接和cpp中的相应槽相关联.该机制的详细文章见 http: ...

  8. Chapter2:Qt5模板库,工具类及控件

    2.1 字符串类 QString类保存16位Unicode值,提供了丰富的操作,查询和转换等函数.  (1):QString提供了一个二元的"+"操作符用于组合两个字符串  (2) ...

  9. QT5:第二章 布局排版控件

    一.简介 在QT组件面板中有Layouts和Spacers两个组件面板 注意:布局排版控件不显示 1.Layouts(布局) Vertical Layout:垂直方向布局,组件自动在垂直方向上分布 H ...

随机推荐

  1. NOIP[2015] 运输计划

    传送门 题目描述 Description 公元 2044 年,人类进入了宇宙纪元.L 国有 n 个星球,还有 n−1 条双向航道,每条航道建立在两个星球之间,这 n−1 条航道连通了 L 国的所有星球 ...

  2. 记 tower.im 的一次重构

    原文in here: http://outofmemory.cn/wr?u=http%3A%2F%2Fblog.mycolorway.com%2F2013%2F05%2F01%2Ftower-refa ...

  3. 【Oracle】安装

    http://www.2cto.com/database/201208/150620.html 呵呵,花了一个多小时,左右把11g安装折腾好了.其中折腾SQL Developer 花了好长时间,总算搞 ...

  4. Filter plugins ? mutate:

    filter { grok { match => [ "message" , "\s*%{IPORHOST:clientip}\s+\-\s+\-\s+\[%{HT ...

  5. 【HDOJ】3285 Convex Hull of Lattice Points

    凸包模板题目. /* 3285 */ #include <iostream> #include <cstdio> #include <cstring> #inclu ...

  6. How to make onActivityResult get called on Nested Fragment

    One of the common problem we always meet in the world of Fragment is: although we could callstartAct ...

  7. ubuntu14.04.2 添加ppa remastersys源 镜像ubuntu系统

  8. VMware Ubuntu安装详细过程

    参考链接: http://blog.csdn.net/u013142781/article/details/50529030

  9. Java字符串的最大长度

    在cpp中为了可移植性,string的长度是string::size_type,突然就想知道java允许的最大字符串长度为多少.看String的源码: public final class Strin ...

  10. Hibernate的fetch

    hibernate抓取策略fetch具体解释一.hibernate抓取策略(单端代理的批量抓取fetch=select(默认)/join)測试用例:Student student = (Student ...