QT5-control-QTimeEdit and QTime, qt5 -- qtimeedit
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QTimeEdit>#include <QTime>class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow(); QTimeEdit* qte[10];};#endif // MAINWINDOW_H
# Include "mainwindow. h "# include <QtDebug> MainWindow: MainWindow (QWidget * parent): QMainWindow (parent) {this-> resize (200,600); this-> centralWidget (); QTime ti1 = QTime (6, 24, 55,432); // default display style qte [0] = new QTimeEdit (ti1, this); qte [0]-> setGeometry (10, 30, ); // specify the format of the display style qte [1] = new QTimeEdit (ti1.addSecs (2), this); qte [1]-> setGeometry ); qte [1]-> setDisplayFormat ("AP hh: mm: ss: zzz"); qte [2] = new QTimeEdit (ti1.addMSecs (100), this); qte [2]-> setGeometry (10,110,150, 30); qte [2]-> setDisplayFormat ("AP hh: mm: ss: zzz "); // convert from string to time QTime ti2; qte [3] = new QTimeEdit (ti2.fromString (" 23:30:30 "," hh: mm: ss "), this); qte [3]-> setGeometry (10,150,150, 30); qte [3]-> setDisplayFormat (" AP hh: mm: ss: zzz "); // convert the date to the specified format string qDebug () <"Current Time" <QTime: currentTime (). toString ("AP hh: mm: ss: zzz"); // calculate the process time QT Ime ti3; ti3.start (); for (int I = 0; I <10000; I ++) {for (int I = 0; I <1000; I ++) {}} qDebug () <"just passed" <ti3.elapsed () <"millisecond";} MainWindow ::~ MainWindow (){}
#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}