QTimer::remainingTime()在win7和CentOS6.5上的差异
来源:互联网 发布:mac初始密码是多少 编辑:程序博客网 时间:2024/05/16 19:33
环境
CentOS
about QT: Qt Creator 2.8.1 , Based on Qt 5.1.1 (GCC 4.6.1, 32 bit)
编译器:GCC 4.9.1
系统:Linux CentOS.com 2.6.32-642.15.1.el6.i686 #1 SMP Fri Feb 24 13:54:50 UTC 2017 i686 i686 i386 GNU/Linux
kit: Desktop Qt 5.1.1 GCC 32 bit
windows
about QT: Qt Creator 4.2.1,Based on Qt 5.8.0 (MSVC 2015, 32 bit)
编译器:MinGW 4.8 32 bit MinGW
系统:windows 7 旗舰版 64 bits
kit: Desktop Qt 5.1.1 MinGW 32 bit
程序概述
每隔3秒钟,textEdit上的数字加1(最初是0),每隔1秒钟,label上的更新当前的距离timeout触发事件的剩余时间,格式为时:分:秒。
表现
centos
在CentOS上程序运行和预想的是一样的。3秒钟一次在textEdit上产生不断变大的数字,在label中显示距离下一次事件发生还剩下多少时间。
win7
在win7上,myTimer::remainingTime()返回结果在第一次变成0后以后一直都是0.
但myTimer是正常让TextEdit的数字每三秒一次的更新,不过myTimer::remainingTime()的返回值在第一次由3变0后就不再变化一直是0了,好像在说,“嘿,哥们儿,你的Timer过期了。”
具体代码
mTimer.pro:
#-------------------------------------------------## Project created by QtCreator 2017-03-08T18:30:37##-------------------------------------------------QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = mTimerTEMPLATE = appSOURCES += main.cpp\ dialog.cppHEADERS += dialog.hFORMS += dialog.ui
dialog.h
#ifndef DIALOG_H#define DIALOG_H#include <QDialog>#include <QTimer>namespace Ui {class Dialog;}class Dialog : public QDialog{ Q_OBJECTprotected: qint8 count; QTimer *myTimer; QTimer *showTimer;public: explicit Dialog(QWidget *parent = 0); ~Dialog();public slots: void update(); void showTime();private: Ui::Dialog *ui;};#endif // DIALOG_H
dialog.cpp
#include "dialog.h"#include "ui_dialog.h"#include <QMediaPlayer>Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog){ ui->setupUi(this); count = 0; myTimer = new QTimer(this); showTimer = new QTimer(this); showTimer->start(1 * 1000); myTimer->start(3 * 1000 ); myTimer->setSingleShot(false); connect(myTimer,SIGNAL(timeout()),this,SLOT(update())); connect(showTimer,SIGNAL(timeout()),this,SLOT(showTime()));}Dialog::~Dialog(){ delete ui;}void Dialog::update(){ count++; ui->textEdit->setText(QString::number(count));}void Dialog::showTime(){ int mesc = myTimer->remainingTime(); int hour = mesc/1000/60/60; int minute = mesc/1000/60 - hour*60; int sec = mesc/1000-hour*60*60-minute*60; QString str; str = str + QString::number(hour)+":"; str = str + QString::number(minute)+":"; str = str + QString::number(sec); ui->leftLabel->setText(str); QFont font("Microsoft YaHei",20); ui->leftLabel->setFont(font);}
main.cpp
#include "dialog.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); Dialog w; w.show(); return a.exec();}
版本更新,恢复正常
17.03.24更新:
我安装最新离线版本的qt后,win7上的怪现象消失了,时间是由3秒变成0秒,然后不断重复这个过程。还是同样的代码,kit也是一样,不过kit和编译器的版本更新了。
about QT: Qt Creator 4.2.1; Based on Qt 5.8.0 (MSVC 2015, 32 bit)
编译器:5.8.0 32 bit MinGW
系统:windows 7 旗舰版 64 bits
kit: Desktop Qt 5.8.0 MinGW 32 bit
- QTimer::remainingTime()在win7和CentOS6.5上的差异
- ipchains 和 iptables 在语法上的主要的差异
- 界面在手机和模拟器上显示的差异
- sizeof()在指针和数组上的差异
- Java和C++在细节上的差异
- Java和C++在细节上的差异(转)
- Android和iOS在交互细节上的差异
- 北京和硅谷在创新上的差异
- Java和C++在细节上的差异(一)
- Java和C++在细节上的差异
- ByteBuffer.allocate()和ByteBuffer.allocateDirect在性能上的差异
- Java和C++在细节上的差异
- python在centos6.5上的升级
- yael在CentOS6.5上的安装
- SVN在centos6.5上的搭建
- Docker在CentOS6.5上的安装
- calloc在4u和5u上性能差异的分析
- pyenv在CentOS6.6上的安装和使用
- vue.js下载安装教程
- mysql并发与锁机制
- TCP滑动窗口和SO_RCVBUF之间的关系
- arm通过tftp从ubuntu主机上下载可执行程序
- activiti工作流源码修改
- QTimer::remainingTime()在win7和CentOS6.5上的差异
- 剑指offer--二维数组的查找
- linux用户管理
- 梯度下降法的三种形式BGD、SGD以及MBGD
- 第39级台阶
- http协议请求,get和post的区别与联系
- Android自定义标题栏ActionBar
- codeforces 785 C. Anton and Fairy Tale (数学 二分搜索)
- IntentService和Service的区别