当前位置:网站首页>Qtime定义(手工废物利用简单好看)
Qtime定义(手工废物利用简单好看)
2022-07-25 15:23:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
QTime::QTime() 默认构造函数,构造一个时,分,秒都为0的时间,如00:00:00.000(午夜)
QTime::QTime(int h, int m, int s=0, int ms = 0) 构造一个用户指定时,分,秒的时间. 其参数有效值为: h:0–23 m:0–59 ms:0–999
QTime QTime::addMSecs(int ms) const 返回一个当前时间对象之后或之前ms毫秒的时间对象(之前还是之后视ms的符号,如为正则之后,反之之前) 如:QTime time(3,0,0); QTime newTime1 = time.addMSecs(1000); QTime newTime2 = time.addMSecs(-1000); 则newTime1是一个比time所指定时间(03:00:00.000)延后1000毫秒也即1秒的时间(03:00:01.000),而newTime2则提前1000毫秒(02:59:59.000)
QTime QTime::addSecs(int nsecs) const 与addMSecs()相同,只是nsecs单位是秒.即返回一个当前时间对象之前或之后的时间对象.
int QTime::elapsed() const 返回最后一次调用start()或restart()到现在已经经过的毫秒数.如果经过了24小时之后,则计数器置0.如果系统时间设置改变,则结果不确定.
int QTime::hour() const 返回时间对象的小时,取值范围(0–23)
int QTime::minute() const 返回时间对象的分钟,取值范围(0–59)
int QTime::second() const 返回时间对象的秒,取值范围(0–59)
int QTime::msec() const 返回时间对象的毫秒,取值范围(0–999)
bool QTime::isNull() const 如果时间对象等于00:00:00.000,则返回true;反之返回false.
bool QTime::isValid() const 如果时间对象是有效的,则返回true;反之返回false.(即:时,分,秒,毫秒都在其取值范围之内)
int QTime::msecsTo(const QTime &t) const 返回当前时间对象到t所指定的时间之间的毫秒数.如果t早于当前时间对象的时间,则返回的值是负值.因为一天的时间是86400000毫秒,所以返回值范围是-86400000–86400000
int QTime::secsTo(const QTime &t) const 与msecsTo()基本相同,只是返回的是秒数,返回值的有效范围是-86400–86400
int QTime::restart() 设置当前时间对象的值为当前系统时间,并且返回从最后一次调用start()或restart()到现在的毫秒数.如果计数器超出24小时,则置0.如果计数器计数时系统时间设置改变,则结果不确定.
bool QTime::setHMS(int h, int m, int s, int ms = 0) 设置当前时间对象的时,分,秒和毫秒.如果给定的参数值有效,则返回true,否则返回false.
void QTime::start() 设置当前时间对象的值为当前系统时间,这个函数实际是结合restart()和elapsed()用来计数的.
QString QTime::toString(const QString &format) const 按照参数format指定的格式用字符串形式输出当前时间对象的时间. 参数format用来指定时,分,秒,毫秒的输出格式.如(hh:mm:ss.zzz) h:表示小时,范围是0–23 hh:用两位数表示小时,不足两位的前面用0补足,如(0点:00,3点:03,11点:11) m:表示分钟,范围0–59 mm:用两位数表示分钟,不足两位的前面用0补足. s:表示秒,范围0–59 ss:用两位数表示秒,不足两位的前面用0补足. z:表示毫秒,范围0–999 zzz:用三位数表示毫秒,不足三位的前面用0补足. AP:用AM/PM显示. ap:用ap/pm显示. 例如: QTime time(14,3,9,42);//设置时间为14:03:09.042 QString i = time.toString(“hh:mm:ss.zzz”);//结果为14:03:09.042 QString j = time.toString(“h:m:s.z”);//结果为14:3:9.42 QString m = time.toString(“h:m:s.z AP”);//结果为2:3:9.42 PM QString n = time.toString(“h:m:s.z ap”);//结果为2:3:9.42 pm
QString QTime::toString(Qt::DateFormat f = Qt::TextDate) const 按照参数format指定的格式用字符串形式输出当前时间对象的时间. 参数的可选值: Qt::TextDate:格式为HH:MM:SS Qt::ISODate:遵循ISO8601的时间表示格式,同样也为HH:MM:SS Qt::LocalDate:字符串格式依赖系统本地设置
—————————————————————————————————————————————-
静态成员函数:
QTime QTime::currentTime() 返回当前的系统时间.
QTime QTime::fromString(const QString &string, Qt::DateFormat format = Qt::TextDate) 使用参数format指定的格式根据参数string指定的时间返回一个时间对象。如果string指定的时间不合法,则返回一个无效的时间对象。 format可选值: Qt::TextDate:格式为HH:MM:SS Qt::ISODate:遵循ISO8601的时间表示格式,同样也为HH:MM:SS Qt::LocalDate:字符串格式依赖系统本地设置
QTime QTime::fromString(const QString &string, const QString &format) 使用参数format指定的格式根据参数string指定的时间返回一个时间对象.如果string指定的时间不合法,则返回一个无效的时间对象. format的格式参看QString QTime::toString(const QString &format) const.
bool QTime::isValid(int h, int m, int s, int ms = 0) 如果参数所指定的时间是合法的,则返回true;反之返回false.
—————————————————————————————————————————————-
静态成员函数不依赖于对象,可以通过类直接调用,与对象无关:
如:获取当前系统时间的小时部分时不需要定义QTime对象
int hour = QTime::currentTime().hour()
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127599.html原文链接:https://javaforall.cn
边栏推荐
- Spark002 --- spark task submission, pass JSON as a parameter
- 在网页上实现任意格式的音视频快速播放功能的开发总结。
- Graph theory and concept
- ML - 语音 - 传统语音模型
- How spark gets columns in dataframe --column, $, column, apply
- MySQL transactions and mvcc
- Hbck 修复问题
- Args parameter parsing
- The difference between Apple buy in and apple pay
- Spark submission parameters -- use of files
猜你喜欢

解决DBeaver SQL Client 连接phoenix查询超时

MySQL installation and configuration super detailed tutorial and simple database and table building method

延迟加载源码剖析:

spark分区算子partitionBy、coalesce、repartition

Distributed principle - what is a distributed system

ML - natural language processing - Introduction to natural language processing

Remember that spark foreachpartition once led to oom

ML - 自然语言处理 - 基础知识

Gbdt source code analysis of boosting

BPSK调制系统MATLAB仿真实现(1)
随机推荐
Flex 布局
获取键盘按下的键位对应ask码
Notes on inputview and inputaccessoryview of uitextfield
VMware Workstation fails to start VMware authorization service when opening virtual machine
《图书馆管理系统——“借书还书”模块》项目研发阶段性总结
Application of C language array in Sanzi chess -- prototype of Queen n problem
The number of query results of maxcompute SQL is limited to 1W
Spark DF adds a column
盒子躲避鼠标
ML - natural language processing - Key Technologies
Application of object detection based on OpenCV and yolov3
Graph theory and concept
看到很多App出现闪烁的图片,特别是会员页面
苹果内购和Apple Pay 的区别
Hbck 修复问题
分布式 | 实战:将业务从 MyCAT 平滑迁移到 dble
MATLAB读取显示图像时数据格式转换原因
UIDocumentInteractionController UIDocumentPickerViewController
Simulate setinterval timer with setTimeout
How to finally generate a file from saveastextfile in spark