QT5-control-QTimeEdit and QTime, qt5 -- qtimeedit

Source: Internet
Author: User

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();}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.