6 years ago (2014-12-15)  Algorithm language |   First to comment  39 
post score 0 times, average 0.0

Recently wrote the first coding problem of QT4: the system time interface and the implementation of the modification of the system time.I summed up the resources on the Internet and made a summary here.

First of all, Qt itself does not provide a time setting function

Qt itself does not provide a time setting function, the implementation of the system to modify the time using the Windows native API function SetSystemTime Therefore, the header file needs to be added # include <windows.h>

Code section

common problem:

  • Someone may find the following code online:

The result of running the above code shows that the time zone is incorrect: GetSystemTime() gets Greenwich time;

  • No problem with the above, the program does not report an error, but the system time does not change

Please run QTcreator as administrator.

  
 

This article has been printed on copyright and is protected by copyright law. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click on the "sponsored author" below to reward the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/qt-how-to-modify-system-time-and-time-zone-error-problem-2.html

Post comment

Style

No Comment

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW